You said it passed HC test. What were the readings. If once it gets hot you can't get it to cool down very fast then you either have a lack of cooling (ie. clogged radiator) or you are generating too much heat (ie. running too lean)
I am going to outline a few things for those who might search this thread.
Back to basics. Lack of cooling has to do with two major components. Fluid flow and radiator efficiency. Fluid flow starts with the water pump. A surprisingly common problem lies in the fact that there are two type of water pumps. Regular and reverse rotation. They look the same on the outside. The impeller inside is the difference. Get the wrong one and your coolant flow is significantly reduced. The water flow is controlled by the thermostat. It holds the flow back to force the engine to hit operating temperature. Thermostats tend to fail either in the closed or open state. A common problem with overheating after replacement lies in the fact that the thermostat can be installed backwards. Replacing the 195 degree thermostat with a lower temp thermostat is a bandaid. You are not fixing the problem, only masking it during certain operating conditions.
Given a good water pump and a good thermostat, only a few things are left in the flow departement. At higher rpms, the lower radiator hose can collapse and reduce the water flow. A good hose has an internal "spring" to keep the hose open. If none of these are the problem, then the radiator may be blocked with corrosion. Surprisingly enough, I have seen quite a few brand new radiators that have low flow due to manufacturing problems.
If the flow is not a problem, then heat transfer from the radiator into the air is the next most likely issue. Radiators require a good flow of air to effect cooling. Driving at highway speeds, the bulk of the air flow is from ram effect through the grill. At slow speeds, the radiator fan is the main contributor. The fan is driven from the serpentine belt, through a thermostatically controlled clutch. This clutch does not couple the rotation from the belt to the fan if it is cool. When hot, it is supposed to "lock" and spin the fan. This fan clutch is a common culprit. When the engine is hot, turn the engine off, if the fan spins by hand freely, the fan clutch is shot. If the engine temps fall when you get up to speed, suspect the fan clutch. If the fan clutch is good, then the issue is air flow throught the radiator. Over time, the small holes that the air uses to flow through the radiator can become clogged with debris or the fins can become bent, reducing the air flow. Spray painting a raditor with too heavy a coat of paint can also clog or even simply reduce the surface conductivity of the fins, reducing the cooling.
There are two other external items that can contribute to overheating as well. First is the air conditioning "radiator" that sits in front of the engine radiator. They can be plugged, blocking air flow. When the AC is on, it significantly heats the air flowing though the main radiator. That is why the auxilliary fan is set to turn on when the AC is on.
The other contributor occurs with automatic transmission equiped vehicles. Automatic trannies generate considerable heat. They are cooled by circulating their hot fluid through an external radiator. In some vehicles, this is a true radiator in front of the standard radiator. In an XJ, there is a small "radiator" inside the normal radiator that transfers the tranny fluid's heat into the antifreeze. A slipping tranny can generate considerable heat, causing a boil over.
Having said all of that, the radiator cap is a very important part of the cooling system. The purpose of the radiator cap is to hold pressure in the cooling system. Physics says that as you increase the pressure, you raise the boiling point of the fluid. The greater the difference between the ambient air temp and the antifreeze temp, the more efficiently the heat can be transferred to the air. The standard thermostat temp is around 195 degrees. Here in Colorado, the boiling point of water is down around 200 degrees, or way lower on the mountain trails. Without the added pressure, the system would boil at normal operating temps. If the radiator cap does not hold its designed pressure, it will allow the fluid to boil and end up in the overflow bottle or the ground. Many parts stores will say a 13 pound cap is correct for an XJ. You really need a 16 lb cap. You should make sure the mating surface of the cap is clean before installing. The rubber gasket degrades with time. You should replace the radiator cap every year or two. You can't tell if it is good by looking. A new radiator cap is a cheap "try it and see" item.
This has been a cursory overview of the cooling system and how it works.
When you say your XJ is overheating, how do you know? If it is not actually boiling over, the problem may not really exist. Inaccurate temp gauge readings are quite common. The temp sender may be defective. It is located on the top of the head on the driver's side at the rear. You may also get inaccurate readings if there is an air bubble in the engine. This keeps the antifreeze from reaching the sensor and yields bad readings. You can loosen the temp sensor slightly until antifreeze starts coming out, to "burp" the system. Lastly the gauge or wiring may be defective. A non-contact IR thermometer is handy to see if the engine is actually overheating.
You can actually have a boil over situation when you have a perfect cooling system. If you run the engine too lean, excessive heat is generated. More heat than the cooling system can handle. The old shade tree technique is to pull a couple of spark plugs and do a plug reading. If the spark plugs are white or very light you are running too lean. Any more, technology comes to the rescue. The same place that does your emissions test can do a tailpipe sniff to measure your HC. This will give you a definitive answer to whether or not you are running too lean.
Running too lean, has several possible causes. At low rpms, a vacuum leak will cause overheating. As rpm's increase, the ratio of leak to actual air going through the throttle body is reduced and the leak has less effect. A clogged injector can also cause lean burn. The computer can acutally tell the injectors to output too little fuel if it gets the wrong sensor info. The O2 sensor normally fails causing the engine to run too rich, but it can go the opposite way as well. The MAP sensor also has a major impact on fuel air ratio. The throttle position sensor also is a major control sensor, but if it is off, it is normally compensated for by the computer monitoring the O2 sensor.
There is actually a condition where you can overheat and not be running too lean. This occurs when the exhaust is restricted. The common culprit here is a clogged CAT, but it can also be a muffler or a pinched exhaust pipe.
Hopefully this short tutorial has given you some insight into the most common overheating causes and will allow you to troubleshoot the problem instead of blindly throwing parts (money) at the problem.
Good luck.