难以解析RSS提要

时间:2013-03-23 04:01:38

标签: iphone ios objective-c ipad cocoa

我正在尝试使用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没有任何价值。我怎么解析这个?

1 个答案:

答案 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.