I want to display the content of a xml file as itself. I dont want to parse it, instead just read its content and display it.
I tried
$content = file_get_contents("test.xml") ;
But the $content has xml in it.ie when I var_dump($content) the output is string(899) " "
Is it possible to read the the file without parsing. Help me please.
Thanks.
This should solve it
$content = htmlentities(file_get_contents("test.xml"));
And this should solve it:
header("Content-Type: text/plain");
$content = file_get_contents("test.xml");
var_dump($content);
It tells the browser you're sending plain text so that the XML is not rendered as HTML tags (which then are unknown and hidden).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With