Reputation: 31
I'd have the following XML structure:
<entry>
<id im:id="595831580">blabla</id>
</entry>
Now I want to parse the id 595831580.
I tried:
$idAtt = $xml->entry->id;
$id = $idAtt->attributes();
$id2 = $id['im:id'];
But this does not work :(
How can I fix it?
Upvotes: 3
Views: 2782
Reputation: 10080
Alright.
You can't use namespace in offsetGet
method of SimpleXMLElement
, but you can in attributes
method:
echo $xml->entry->id->attributes("im",TRUE)->id;
Check out this comment for one more demo.
Upvotes: 5
Reputation: 6726
Not sure but maybe something like this
$attr = $xml->id[0]->attributes();
echo $attr['im:id'];
Upvotes: 0