By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

Google Chrome Comments Out XML Declaration

P: 72
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.

Share this Question
Share on Google+
2 Replies


drhowarddrfine
Expert 5K+
P: 7,435
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

P: 72
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.