looping through xml nodes where a type is "Array"
Im having some trouble looping through some xml data.
The xml file is structured like this:
<users type="array">
−<user>
<id>14527576</id>
</user>
−<user>
<id>14527576</id>
</user>
−<user>
<id>14527576</id>
</user>
My php to loop through it looks like this
$xml = simplexml_load_string($rawxml);
foreac开发者_运维百科h($xml->users AS $key){
$id = $key->user->{"id"};
But its not throwing errors, or returning anything
Users is your root element. You need just to enumerate it.
$xml = simplexml_load_string( $rawxml );
foreach($xml as $user){
print $user->id . '<br />';
}
精彩评论