Forum Moderators: open

Message Too Old, No Replies

How do you make PHP display raw XML

         

brucec

8:26 pm on Mar 2, 2006 (gmt 0)

10+ Year Member



I am creating XML in a PHP file from a MySQL database and just want the web page to look like raw XML or how do I open an XML file and make it look like XML?

I find a lot of tutorials on how to open an XML file and make it look nice through SAX, DOM, or XSL. I just want to create raw XML and find it nowhere on the web.

Can anyone help?

dmorison

8:42 pm on Mar 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is pretty much just down to sending the text/xml content-type header, a la:

<?php
header("Content-Type: text/xml");

// dynamically generate and output your XML here
?>

brucec

8:59 pm on Mar 2, 2006 (gmt 0)

10+ Year Member



Thanks for the quick response. It works. I have been working well with XML and PHP for the last 3 years and have never had a need for that and it ironically turned out be the easiest line of code! Thanks.