Let's go through it step by step.
First of all, I don't understand what you are asking with this:
I did a search/replace for the "<" and ">" characters and replaced with "<" and ">" respectively. Is that wrong?
Could you come again on that one?
No, the latter method (< won't execute. It will look the same on the HTML page, as < is the HTML entity for a <
Validate. If you run <xmp> through the W3C's validator, it will not validate. Using < will, however.
If you want your code to keep it's layout, you will have to add <br> after each line.
If you show me the code you want displayed on your page, I can show you how to write it so it displays as code...