OK, now were getting somewhere. Now we need to know the year model. Early XJ's used an old fashioned speedometer cable running from the xfer case to the back of the speedometer. If you had a cruise control, the cable terminated into a small speed sensor a few inches behind the speedometer and then a short cable ran from the sensor to the speedo. If this is what you have, you most likely need a new speedo cable. They are quite cheap and can be had at Autozone or the like for around $10 or less.
The newer models, and sorry I don't remember the switch over year, did away with the mechanical speedo cable and went to an electronic sensor that plugged into the xfer case.
Hope that helps. To tell the difference, crawl under and look at the xfer case and see if it has a mechanical cable or a pair of wires.