Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing PHP File Output as XML in Firefox (and other browsers) [duplicate]

Tags:

php

xml

firefox

I have a PHP file which echoes an XML output. However, whenever I go to view that PHP file through Firefox (I haven't tried IE or Chrome), I get a raw text output like seen in this image:

http://numberonekits.com/Screenshot.png

It seems to me that, since the file is a PHP file, Firefox interprets it as such and does not try to display it as an XML tree, despite its XML heading. I am aware that one solution would be to send the output to a separate file with a .xml extension, but I know there must be an easier way. I guess what I am really trying to find out is how to get Firefox to recognize the XML format and display it as it should. Any help is greatly appreciated.

like image 259
danielmhanover Avatar asked Oct 03 '11 22:10

danielmhanover


1 Answers

Tell the browser you are sending it an XML file:

header('Content-Type: text/xml');
like image 86
NullUserException Avatar answered Oct 04 '22 10:10

NullUserException