0
votes

I wish to include in an email the entire xml string (inlcuding headers, tags etc) as a backup to copy/paste. If I use the following:

<?php $xml_content = file_get_contents('http://www.w3schools.com/xml/note.xml'); echo $xml_content; ?>

It shows: Tove Jani Reminder Don't forget me this weekend!

Rather than the full string which would be:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note> 
 <to>Tove</to> 
 <from>Jani</from> 
 <heading>Reminder</heading>
 <body>Don't forget me this weekend!</body>
</note>
1
It does return the full XML string. If you are viewing from a browser, try to view source. - Sutandiono

1 Answers

3
votes

You have to set the page content type to xml or plaintext if you want it to output the file entirely.

header('Content-Type: text/xml');

or if this doesn't work, then

header('Content-Type: text/plain');