Kiran Panesar
Kiran Panesar

Reputation: 3204

Parsing YouTube XML

I'm looking to do a little iOS app that uses has some very basic YouTube interaction. When I say basic, I really mean it: All it needs to do it pull in the uploads from a particular user, the videos' links, titles and maybe a thumbnail.

I've been looking at the Google developer docs for YouTube and nothing seems to be of help. It seems that the data is stored in an XML format, but it seems completely different to the structure of the sample XML in the docs. I don't know whether I'm using the wrong link (this is a sample of what I'm looking at now), but I just get a really messy XML document.

I've really no idea where to start on this one (with regards to a parser) - it just looks so messy. If someone could point me in the right direction with this, maybe even a with some sample code on a parser, I'd be incredibly grateful.

Upvotes: 1

Views: 1498

Answers (4)

Ken W
Ken W

Reputation: 999

The XML link you provided looks like the atom feed. If you don't feel like parsing the XML in your code, you can try the TouchRSS (https://github.com/TouchCode/TouchRSS) which I used to parse the youtube RSS feed. The RSS feed version should be in version 2 so the url you provide should change to http://gdata.youtube.com/feeds/base/users/DJ3Lau/uploads?orderby=updated&alt=rss&v=2.

Upvotes: 1

Jeremy
Jeremy

Reputation: 9030

Here's a very concise and easy-to-read example using NSXMLParser. It provides an example xml and shows you how to parse its elements and populate a custom object with the values.

Upvotes: 2

Vineet Bhatia
Vineet Bhatia

Reputation: 2533

Have you considered making use of gdata-objectivec-client api http://code.google.com/p/gdata-objectivec-client/ It comes with samples which provide exactly what you are looking for.

Upvotes: 2

user1095058
user1095058

Reputation: 75

i can suggest you to use LIBXML 2.2 it's easy to use and you can use Xpath Query to fetch whatever you want from any messy file.

To learn how to use that look at this page. link

Upvotes: 1

Related Questions