开发者

Parse youtube playlist on iphone sdk/ iOS

Since Days i'm tr开发者_如何学Pythonying to parse a YOUTUBE-XML-Feed by using GDATA-API for iOS.

http://code.google.com/intl/de-DE/apis/youtube/2.0/developers_guide_protocol_channel_search.html

   NSDictionary *namespaces = [NSDictionary dictionaryWithObjectsAndKeys:
        @"http://www.w3.org/2005/Atom", @"",
        @"http://schemas.google.com/g/2005", @"gd",
        @"http://a9.com/-/spec/opensearch/1.1/",@"opensearch",
        @"http://gdata.youtube.com/schemas/2007",@"yt",
        @"W/"DkYGRH48fCp7ImA9Wx5WFEw."",@"gd:etag",
        nil];

 NSError *error = [[NSError alloc] init];
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:receivedData options:0 error:nil];

 NSArray *elements = [doc nodesForXPath:@"//entry" namespaces:namespaces error:&error];

I don't get any results. Does anyone got an solution to this? Thanks in advance!


this is how I use this API

NSArray *entries = [doc.rootElement elementsForName:@"entry"];
for (GDataXMLElement *e in entries) {
// do something..
}


There is documentation on the GData Objective-C API, and a sample application for using the YouTube GData API is here.


I encountered a similar problem, it doesn't seem to deal well with a prefixless namespace.

Try changing:

@"http://www.w3.org/2005/Atom", @"",

to

 @"http://www.w3.org/2005/Atom", @"atom",

and your xpath:

@"//entry"

to

@"//atom:entry" 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜