- simplexml_load_string: documentation ( source)
<?php
function ReadXml($xmlstr)
{
$xml = simplexml_load_string($xmlstr);
foreach($xml as $key=>$val) {
print $key;
if(!empty($val)) print ':' . $val;
}
}
$xmlstr= '<Address><to>James</to><from>Jani</from><heading>Reminder</heading><body>Please check your mail.</body></Address>' ;
ReadXml($xmlstr);