【问题标题】:Parse RSS by GDataXML通过 GDataXML 解析 RSS
【发布时间】:2012-09-24 17:44:13
【问题描述】:

我想解析具有相同名称但不同值的子节点的 rss。在这种情况下,我想解析来自子名称“类别”的值。

这里是 RSS 格式:

<item><title>HAC Algorithm by holiccorp</title>
<link>http://www.freelancer.com/projects/PHP-Javascript/HAC-Algorithm.html</link>
<description>Need someone good at javascript coding and HAC Algorithm.    I need someone   to create and analyze the code,script and logic.    More details will be given after discussion.    ASAP project. (Budget: &#36;30-&#36;250 USD, Jobs: Algorithm, HTML, Javascript, PHP, Website Testing)</description>
<pubDate>Sun, 23 Sep 2012 13:20:17 -0400</pubDate>
<guid isPermaLink="false">Freelancer.com_project_2509687</guid>
<category domain="http://www.freelancer.com/jobs/">Algorithm</category>
<category domain="http://www.freelancer.com/jobs/">HTML</category>
<category domain="http://www.freelancer.com/jobs/">Javascript</category>
<category domain="http://www.freelancer.com/jobs/">PHP</category>
<category domain="http://www.freelancer.com/jobs/">Website Testing</category>
<coop:keyword>Algorithm</coop:keyword>
<coop:keyword>HTML</coop:keyword>
<coop:keyword>Javascript</coop:keyword>
<coop:keyword>PHP</coop:keyword>
<coop:keyword>Website Testing</coop:keyword>
<coop:keyword>project 2509687</coop:keyword>
<coop:keyword>HAC Algorithm</coop:keyword>
</item>

我做了这样的事情:

NSArray *channels = [rootElement elementsForName:@"channel"];
for (GDataXMLElement *channel in channels) {            

    NSString *blogTitle = [channel valueForChild:@"title"];                    
    NSLog(@"blogTitle %@",blogTitle);
    NSArray *items = [channel elementsForName:@"item"];
    for (GDataXMLElement *item in items) {

        NSString *articleTitle = [item valueForChild:@"title"];
        NSString *articleUrl = [item valueForChild:@"link"];            
        NSString *articleDateString = [item valueForChild:@"pubDate"];
        NSString *articleDescription = [item valueForChild:@"description"];
        NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC822];
        NSDate *timeStamp = [NSDate date];
        NSString *category = [item valueForChild:@"category"];
 }

在这段代码中,我只从子名称类别中获得了第一个值。我如何解析这个孩子的所有价值并在一行中显示?有什么想法吗?

非常感谢

【问题讨论】:

  • 我认为这一行是你的问题..freelancer.com/jobs/">HTML</category> .. 你得到了哪个值,哪个没有得到?或者给我发送 XML 链接或完整的 xml 字符串...

标签: iphone objective-c rss gdataxml


【解决方案1】:

GDataXML属性解析方法你要多学习

以下链接可能对您有所帮助

example-code-for-parsing-xml-and-get-attributes

parsing-xml-attribute-using-gdataxmldocument

查看 GData 示例 here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-12
    • 1970-01-01
    • 2012-02-27
    • 2012-01-24
    • 2012-02-21
    • 1970-01-01
    • 2012-02-17
    • 1970-01-01
    相关资源
    最近更新 更多