我正在尝试使用NSXMLParser
解析RSS Feed(http://www.themostunrealbeats.com/?feed=rss2)。我很难找到文章中的图片。这是图片在RSS提要中的位置。
<media:content url="http://themostunrealbeats.files.wordpress.com/2012/03/madeon.png?w=400" medium="image">
<media:title type="html">madeon</media:title>
</media:content>
具体来说,我想要http://themostunrealbeats.files.wordpress.com/2012/03/madeon.png
。然而在NSXMLParser
的委托方法中,我找不到任何东西。
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if ([element isEqualToString:@"media:content"]) {
NSLog(@"%@", string);
[content appendString:string];
}
}
string
没有任何价值。我怎么解析这个?
答案 0 :(得分:5)
// NSXMLParser has a following method
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
// In this method parameter 'attributeDict' will return you all the sub attributes of main attribute.
// In your case its 'url' of Picture.
// I hope this will help you. Check this out.