I've been struggling in finding a solution that allows me to really parse an Atom file, more specifically the YouTube video feed (see: http://gdata.youtube.com/feeds/videos/kHmvkRoEowc)
SimpleXML gets most of it, but not the important parts. If you see near the bottom of the page of that atom file, tags like <media:category> are simply ignored.
Any solutions at all?
[SOLVED] Parse real Atom files using PHP
Moderator: General Moderators
[SOLVED] Parse real Atom files using PHP
Last edited by phice on Wed Oct 24, 2007 1:18 pm, edited 1 time in total.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
could try the PHP DOM functions - they're a little more involved than simpleXML, but quite complete as far as I can tell.
That is probably the most confusing thing I've ever seen. Upon searching for relative tutorials on PHP DOM, pretty much every tutorial I saw was about parsing very simple RSS files, and not advanced Atom files, as previously linked to in the first post. Any idea where I can find a tutorial or two to specifically parse Atom files?
http://simplepie.org/ is nice.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I've already tried that script and it doesn't seem to realize that the link provided (http://gdata.youtube.com/feeds/videos/kHmvkRoEowc) is a real feed.pickle wrote:http://simplepie.org/ is nice.
Atom feeds are expected to have a parent <feed> element, but YouTube has skipped that oh-so-important element in their new API. SimplePie doesn't think it's an Atom feed because it's not. It IS certainly valid XML, however, so I would recommend an XML parser such as XMLize (http://hansanderson.com/php/xml/).