我正在做一个测试,我正在构建一个新闻提要 iOS 应用程序,使用像这样的 rss 提要:http ://www.20minutos.es/iphoneapp/feeds/home/
我快完成了,但我找不到缩略图的链接。我正在做这样的解析,我可以找到一些附件,enclosure2x,thumbnail,thumbnail2x,但它们都是空字符串:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
element = elementName;
if ([element isEqualToString:@"item"]) {
item = [[NSMutableDictionary alloc] init];
title = [[NSMutableString alloc] init];
link = [[NSMutableString alloc] init];
image = [[NSMutableString alloc] init];
image2x = [[NSMutableString alloc] init];
comments = [[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if ([elementName isEqualToString:@"item"]) {
[item setObject:title forKey:@"title"];
[item setObject:link forKey:@"link"];
[item setObject:image forKey:@"image"];
[item setObject:image2x forKey:@"image2x"];
[item setObject:comments forKey:@"comments"];
[feeds addObject:[item copy]];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if ([element isEqualToString:@"title"]) {
[title appendString:string];
} else if ([element isEqualToString:@"link"]) {
[link appendString:string];
} else if ([element isEqualToString:@"veinteminutos:numComments"]) {
[comments appendString:[string stringByReplacingOccurrencesOfString:@" " withString:@""]];
}
//NSLog(@"string: %@ \nelement: %@ \n\n\n", string, element);
}
这是我第一次解析 rss 提要,所以我真的不知道在那里寻找什么。
谢谢