I’m loading an XML file in via simpleXML. I’m a novice at best at PHP and new to parsing PHP but I’m a little confused
I’m trying to understand the structure of the variable I have stored, so I tried var_dump()
The thing that’s confusing me is the data I’m looking for that’s in the XML is not anywhere in the dumped data
http://gdata.youtube.com/feeds/api/videos?q=surfing&max-results=25
That’s the URL I’m using at the moment. However, for example, the duration/seconds is nowhere to be found in the dumped variable data– where is it and how do I access it?
here is the output I’m getting: http://pastebin.com/ggumXTEu
The path to
<yt:duration>is/feed/entry/media:group/yt:duration/You don’t see these elements when using var_dump(), because they belong to a namespace(media and yt).
You may use SimpleXMLElement->children() to access these elements, you need to supply the namespace-uri as argument to
children()