Maybe. It has to do with the angle the spoke leaves the rim. The flanged alloy rims that the 650s used will probably fit the front, and maybe fit the back. The answer to your question is diameter of the 400's hubs, and the width at the flanges where the spokes go through. If too wide or narrow, the spokes will be bent on their way to the rim.
If used for rough riding, you want a cross 3 minimum setup, better yet, a cross 4. That means the spoke crosses 3 other spokes on it's same side on the way to the rim. That makes for a longer spoke, but a stronger wheel. Most dirt bikes have wide hubs, in order to make a stronger wheel.
The other idea would be fit a DT250/400 rear wheel onto the XS; you'd need to see if the axle was the same diameter. My guess it is, or very close. If so, other than aligning the chain, you're all set. The front could use a rim from the 650, laced to the 400 hub.
if you're really serious about this, contact Buchanan's; they can provide anything you want. if you do it right, you'll never need to mess with it again. These guys have been in business since the 60s, and they really do the job. One thing that often happens is someone has a good idea, but does it in such a way that it doesn't work or works poorly. These guys will make whatever you want and it will definitely fit and last. In the end, cheaper.
Here:
http://www.buchananspokes.net/categories/akront.asp
i'm actually considering doing exactly this. But I want a SR500/XS650 front end, because I want the better forks. It will fit right on if you bring the triples over as well. it is a nice upgrade, a lot cheaper than other bike's stuff, and cheap and available repair parts. By putting race Tech cartridge emulators in the SR/XS forks, I have something that handles as well as you could use on a bike like this, and fits easily and looks like it came from the factory this way. make it too nice, someone will steal it.
The XS400 is a nice bike, but even going to super deluxe suspension, you're still held back by the frame and steering geometry. So at some point, you need to decide what you're going to use it for and work towards that.