How to echo xml file in php
You can use HTTP URLs as if they were local files, thanks to PHP's wrappers
You can get the contents from an URL via file_get_contents() and then echo it, or even read it directly using readfile()
$file = file_get_contents('http://example.com/rss');
echo $file;
or
readfile('http://example.com/rss');
Don't forget to set the correct MIME type before outputing anything, though.
header('Content-type: text/xml');
Here's what worked for me:
<pre class="prettyprint linenums">
<code class="language-xml"><?php echo htmlspecialchars(file_get_contents("example.xml"), ENT_QUOTES); ?></code>
</pre>
Using htmlspecialchars will prevent tags from being displayed as html and won't break anything. Note that I'm using Prettyprint to highlight the code ;)