Using xml: How to foreach multiple SimpleXML using PHP on newest questions tagged xml – Stack Overflow

I am using Last.fm get event by venue API call. It returns an XML with multiple objects

print_r($xml)

This is the result

SimpleXMLElement Object
(
    [events] => SimpleXMLElement Object
        (
           [event] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                           ....
                        )
                    [1] => SimpleXMLElement Object
                        (
                           ....
                        )
                    ....
                )
        )
)
SimpleXMLElement Object
(
     .............
     .............
)

I can apply foreach loop like this

foreach($xml->events->event as $data) {
    ...
}

But it returns only data from first object. How can I get or loop data from other objects?

See Answers


source: http://stackoverflow.com/questions/9085177/how-to-foreach-multiple-simplexml-using-php
Using xml: using-xml



online applications demo