I own a G34, a G26, and a XD 5" 45acp. I've also fired my brother's G21 several times, so I feel I have a good idea of what the various models are like. Both guns are very similar in how they operate, cost, capacity, etc.
In 45acp, I feel the XD is a much better gun. The G21's grip generally sucks unless you have somewhat larger hands. Firing the G21 beats up my hands and wrists, and my accuracy is horrible with it (due to my inability to get a proper grip). The XD by comparison has a much more "natural" grip that even small handed shooters can be comfortable with. Another plus for the XD is that you can shoot lead ammo out of the stock barrel.
The pluses to the Glock is that the trigger is much cheaper to modify, and has a better reset out of the box. Also, Glock mags tend to be cheaper (though if you look hard, you can find the XD mags for about $20ish).
If you can, fire them both and decide for yourself. Thats what I did, and it made my decision very easy.