467,114 Members | 1,410 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,114 developers. It's quick & easy.

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.

  • viewed: 2449
Share:
2 Replies
drhowarddrfine
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
By using this site, you agree to our Privacy Policy and Terms of Use.