generate a dynamic XML response from a PHP script
Posted: Sun Aug 19, 2007 8:19 pm
I am trying to generate a dynamic XML response from a PHP script. Based on what I have learned about the process so far, it is my understanding that the following segment of code should generate a XML response and will appear as an XML tree in when viewed in Internet Explorer showing XML tags and content.
However what I get looks like a regular HTML page.
If I save the document to a file with .xml extention it is viewed as a tree in IE, however when generated dynamically it looks like a regular html document.
I hope I am expressing myself clearly. There are alot of new concepts here for me.
Here is a simplified example.
However what I get looks like a regular HTML page.
If I save the document to a file with .xml extention it is viewed as a tree in IE, however when generated dynamically it looks like a regular html document.
I hope I am expressing myself clearly. There are alot of new concepts here for me.
Here is a simplified example.
Code: Select all
<?php
header('Content-Type: text/xml; charset=UTF-8');
header('Content-Disposition: inline; filename="test.xml"');
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo <<<BODY
<invoice>
<to>12345</to>
<from>TP937373</from>
<heading>Invoice Header</heading>
<body>Invoice Detail</body>
</invoice>
BODY;
?>