I'm getting an XML file and converting to array using:
$myObject = simplexml_load_string(file_get_contents($xmlUrl));
With var_dump I can see the returning object is:
object(SimpleXMLElement)#614 (4) {
["@attributes"]=>
array(5) {
["id"]=>
string(2) "77"
["parentCategoryId"]=>
string(4) "6420"
["isFinal"]=>
string(4) "true"
["hasOffer"]=>
string(4) "true"
["hasProduct"]=>
string(4) "true"
}
}
I need to get the id. I've already tried $myObject->@attributes
, $myObject->attributes
and $myObject->{'@attributes'}
but no success, the var_dump
always return an empty object.