If you simply want to display it on a web page (e.g. within HTML) I use <pre><xmp>$xml</xmp></pre>
<pre><xmp>$xml</xmp></pre>