The X pipe should go as close to the front section of the exhaust as possible. Let me reword that...The X pipe should go directly after the final collection point of the exhaust.
I personally will be running a magnaflow X pipe resonator in the section before the secondary cats.
For an H pipe the location is generally used more for a tuning aspect. It's install location will depend on what tone you're attempting to generate/eliminate.
Very high level information and there is a ton more to it than that, but its the generalization to your questions.