472,139 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

Google Chrome Comments Out XML Declaration

Hi,

If I use php to echo an XML file directly to the response, all I see is the XML text.

This is because Google Chrome comments out the XML declaration at the start of the text, causing it to treat the rest of the XML as an HTML document.

If I view source, copy and paste the XML exactly as it is into an actual XML file, place this file in the exact same directory on my web site as the php file, and try to load the XML file, it works correctly.

Is there some trick to the response I need to do in order to emulate an XML download? (e.g. headers)

Regards,
Rob.
Oct 9 '11 #1

✓ answered by drhowarddrfine

If you are saving a file with an xml extension, your server is most likely recognizing that and automatically serving it as application/xml. If you just echo the xml, it's treated as text only.

2 2660
drhowarddrfine
7,435 Expert 4TB
If you are saving a file with an xml extension, your server is most likely recognizing that and automatically serving it as application/xml. If you just echo the xml, it's treated as text only.
Oct 9 '11 #2
Yup,

Added a call to header("Content-type: application/xml");
prior to calling the echo.

That fixed it.

Cheers,
Rob
Oct 16 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Guy Macon | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.