0

Hello. I have this below

SimpleXMLElement Object
(
    [item] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [id] => plid_2
                            [name] => Playlist
                            [ro] => ro
                        )

                    [content] => SimpleXMLElement Object
                        (
                            [name] => Playlist
                        )

                    [item] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [id] => plid_5
                                            [uri] => file:///C:/Users/ca/Desktop/bla.mp3
                                            [name] => bla.mp3
                                            [ro] => rw
                                            [duration] => 650
                                            [current] => current
                                        )

                                    [content] => SimpleXMLElement Object
                                        (
                                            [name] => bla.mp3
                                        )

                                )

My question is.. How do I access name, and duration etc in a foreach loop?

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by reco21
0
$xml = simpleXML_load_file($url);
foreach ($xml->item as $item) {
    echo (string)$xml->item->item->attributes()->name;
}

kk nvm

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.