change mime type of output in php
header('Content-type: application/xml');
More information available at the PHP documentation for header()
Set the Content-Type
header:
header('Content-Type: text/xml');
Though you should probably use "application/xml" instead.
You should send a Content-Type
header before you send any output.
header('Content-Type: text/xml');
I will answer to the update, since the previous answers are good.
I have read that Internet Explorer is well known for ignoring Mime type headers (most of the time?) to rely on content of the file (which can cause problems in some cases).
Mmm, I did a simple test:
<?php
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root><foo a="b">Tada</foo></root>';
?>
Internet Explorer 6 displays it correctly as XML. Even if I remove the xml declaration.
You should indicate which version is problematic.
Actually, as I wrote above, with IE (6 at least), you don't even need a content-type, it recognize XML data and display it as a tree. Is your XML correct?
[Update] Tried with IE7 as well, adding ?format=xml too, still displaying XML correctly. If I send malformed XML, IE displays an error. Tested on WinXP Pro SP2+