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?

$xml = simpleXML_load_file($url);
foreach ($xml->item as $item) {
    echo (string)$xml->item->item->attributes()->name;
}

kk nvm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.