1

我正在尝试使用. NSXMLParser我很难在文章中找到图片。这是图片在 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没有价值。我该如何解析这个?

4

1 回答 1

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.
于 2013-03-23T04:26:17.917 回答