php - Accessing @attribute from SimpleXML -
i having problem accessing @attribute
section of simplexml object. when var_dump
entire object, correct output, , when var_dump
rest of object (the nested tags), correct output, when follow docs , var_dump
$xml->office->{'@attributes'}
, empty object, despite fact first var_dump
shows there attributes output.
anyone know doing wrong here/how can make work?
you can attributes of xml element calling attributes() function on xml node. can var_dump return value of function.
more info @ php.net http://php.net/simplexmlelement.attributes
example code page:
$xml = simplexml_load_string($string); foreach($xml->foo[0]->attributes() $a => $b) { echo $a,'="',$b,"\"\n"; }