开发者

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

开发者 https://www.devze.com 2023-04-10 03:37 出处:网络
This question already has answers here: Output raw XML using php (5 answers) Closed 3 years ago. I have a PHP file which echoes an XML output. However, whenever I go to view that PHP file t
This question already has answers here: Output raw XML using php (5 answers) Closed 3 years ago.

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 aw开发者_运维问答are 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.


Tell the browser you are sending it an XML file:

header('Content-Type: text/xml');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号