Send xml to client as Content-Type text/xml in PHP
Description
The following code shows how to send xml to client as Content-Type text/xml.
Example
<?php/*from w w w . j a v a 2 s .co m*/
$xml = simplexml_load_file('test.xml');
header('Content-Type: text/xml');
echo $xml->asXML();
?>
The following code is for test.xml.
<?xml version='1.0' encoding='utf-8'?>
<inventory>/*from w w w . j a v a 2 s . co m*/
<book isbn13='1'>
<title>PHP</title>
<author>Jack</author>
<publisher>Publisher 1</publisher>
<description>PHP Book</description>
</book>
<book isbn13='2'>
<title>XML</title>
<author>Jane</author>
<publisher>Publisher 2</publisher>
<description>XML Book</description>
</book>
</inventory>
The code above generates the following result.