几天以来,我一直在尝试使用iOS的GDATA-API来解析YOUTUBE-XML-Feed。
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];我没有得到任何结果。有人有解决这个问题的办法吗?提前感谢!
发布于 2010-09-25 23:21:13
这就是我使用这个API的方法
NSArray *entries = [doc.rootElement elementsForName:@"entry"];
for (GDataXMLElement *e in entries) {
// do something..
}发布于 2010-09-26 04:04:50
GData Objective-C应用编程接口上有documentation,使用YouTube GData应用编程接口的示例应用程序是here。
发布于 2010-12-03 00:15:58
我遇到了一个类似的问题,它似乎不能很好地处理无前缀的名称空间。
尝试更改:
@"http://www.w3.org/2005/Atom", @"",至
@"http://www.w3.org/2005/Atom", @"atom",和您的xpath:
@"//entry"至
@"//atom:entry" https://stackoverflow.com/questions/3794284
复制相似问题