1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php $xml = '<xml> <status>0</status> <error code="111">Error message text goes here.</error> </xml>'; $xml = simplexml_load_string($xml ); echo '<pre>'; print_r($xml); echo '</pre>'; echo "error code" . $xml->error['code']; ?>
1 2 3 4 5 6
<pre>SimpleXMLElement Object ( [status] => 0 [error] => Error message text goes here. ) </pre>error code111