如何在XML下打印xml代码?

print this xml in xml format ?

'<availabilityResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <hotel id="123456789">
     <offers>
     <offer total="435.00" currency="EUR">
     </offer>
     </offers>
     </hotel>
     <errors>
     <error type=”E002”>Unknown hotel identifier: 32165487</error>
     <error type=”E002”>Unknown hotel identifier: 951357</error>
     </errors>
    </availabilityResponse>'

print this xml in xml format

<?php

$string = <<<XML
<availabilityResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <hotel id="123456789">
     <offers>
     <offer total="435.00" currency="EUR">
     </offer>
     </offers>
     </hotel>
     <errors>
     <error type="E002">Unknown hotel identifier: 32165487</error>
     <error type="E002">Unknown hotel identifier: 951357</error>
     </errors>
    </availabilityResponse>
XML;

header('Content-type: text/xml');
$xml = new SimpleXMLElement($string);

echo $xml->asXML();

This will output the xml file formated as xml. You had an error in your xml though which i fixed. <error type="E002"> must be in double-quotes it's xml-attribute.