The xd 9 will NOT shoot .40 s&w! Any 9mm parabellum loading is less powerful than 40 s&w. There's NO way I would choose a 9mm over a .40 s&w,and indeed would rather have a .45 over the .40.especially since it's available in same size gun. Check out the XD compact in .45.
The ONLY advantage a 9mm has over the more serious defense rounds is the fact that they are quite a bit cheaper to shoot.
The 9 cannot shoot .40 and it is less powerful than the .40, however power isn't always the key. Placement should always come first, with a 9 you will be able to afford to shoot more, and should become better at handling your pistol. If price and affordability isn't a problem, you will see most people lean towards the .45 as it is a hard round to beat. Make sure that whatever choice you make is based on what you need and not what people tell you.
While I agree that 9mm is easier on pocketbook as far as ammo-in no way would I get 1 because I would still wanna upgrade later to a .45 and you can buy a LOT of 45 ammo for the price of buyin a 9mm first,then getting a "serious" defense pistol later. I don't believe anybody that says a .45 "kicks too hard" anyway. It's ALL in the training.
I bought the .40 and my buddy bought the 9mm. I've shot both side by side and am now wishing I had gotten the 9mm since ammo prices went up. The 9 feels a bit nicer too. The .40 has a little extra snap the 9mm doesn't. Also, the 9mm holds 16 rnds in the mag as opposed to 12 for the .40 I like to shoot, not just keep a gun around for show. For protection I use my 1911 .45