当前位置:  开发笔记 > 编程语言 > 正文

使用适用于iPhone的NSXMLParser处理RSS标签

如何解决《使用适用于iPhone的NSXMLParser处理RSS标签》经验,为你挑选了1个好方法。

我发现以下代码用于解析RSS但它似乎不允许嵌套元素:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{     
    NSLog(@"ended element: %@", elementName);
    if ([elementName isEqualToString:@"item"]) {
        // save values to an item, then store that item into the array...
        [item setObject:currentTitle forKey:@"title"];
        [item setObject:currentLink forKey:@"link"];
        [item setObject:currentSummary forKey:@"summary"];
        [item setObject:currentDate forKey:@"date"];
        [item setObject:currentImage forKey:@"media:thumbnail"];

要使用的RSS是:

    Knife robberies and burglaries up
The number of robberies carried out at knife-point has increased sharply and burglaries are also up, latest crime figures indicate
http://news.bbc.co.uk/go/rss/-/1/hi/uk/7844455.stm
http://news.bbc.co.uk/1/hi/uk/7844455.stm
Thu, 22 Jan 2009 13:02:03 GMTUK


我需要从"media"标签中提取"url"元素.

谢谢马丁



1> August..:

您需要在元素启动时获取属性(包括URL):

parser:didStartElement:namespaceURI:qualifiedName:attributes:

推荐阅读
Gbom2402851125
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有