GDataXML parsing error

Discussion in 'iOS Programming' started by nashyo, Apr 1, 2012.

  1. nashyo, Apr 1, 2012
    Last edited: Apr 1, 2012

    nashyo macrumors 6502


    Oct 1, 2010
    I'm using GDataXMLNode

    NSURL *NewsFeed = [[NSURL alloc] initWithString:@""];
        NSData *xmlData = [[NSMutableData alloc] initWithContentsOfURL:NewsFeed];
        NSError *error;
        GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:&error];
        if (doc == nil) { return nil; }
        //NSLog(@"%@", doc.rootElement);
        News *news = [[News alloc] init];
        NSArray *extractedArticles = [doc.rootElement elementsForName:@"item"];
        if (extractedArticles.count > 0) {
            NSLog(@"Array contains something");
        } else {
            NSLog(@"Array is empty");
    In console:
    NSLog(@"%@", doc.rootElement); would produce loads of xml data in console, so source is fine.

    NSLog Array is empty.

    i do not understand why elementsForName @"item" is not found.

    The beginning of the source looks like this

    2012-03-31 21:31:50.208 GDataXMLExperiment[444:f803] GDataXMLElement 0x6b2c4a0: {type:1 name:rss xml:"<rss version="2.0"><channel>
    <title>1000 Lives Plus: Latest News</title><link></link>
    <description>Latest News</description>
    <copyright>Copyright NHS Wales 2012</copyright>
    <lastBuildDate>Sat, 31 Mar 2012 21:31:48 GMT</lastBuildDate>
    <title>National and international approaches to improvement</title>
    <description><div>The latest edition of the 1000 Lives Plus e-newsletter contains news of the forthcoming national roll-out of a new early warning score to detect illness, new initiatives to reshape stroke services, and details of an international conference for healthcare students.</div></description>
    <pubDate>Mon, 12 Mar 2012 09:47:37 GMT</pubDate><source url="">1000 Lives Plus</source>
    <item><title>Improving the patient experience through Transforming Care</title><description><div>Nurses spending more time at the bedside, improved ward environments and a significant reduction in pressure ulcers are just some of benefits patients have received thanks to the Transforming Care programme, which is being celebrated today at a special event in Cardiff.</div></description><link></link><pubDate>Wed, 07 Mar 2012 11:05:28 GMT</pubDate><source url="">1000 Lives Plus</source></item><item><title>New whit
    i changed elementsForName @"item" to @"channel" and i got 1 step further. i found 89 'items' within that array. however, i can't find 'descriptions'...
  2. nashyo thread starter macrumors 6502


    Oct 1, 2010
    I figured it out now. I had to extract all the items into an array, and then perform fast enumeration on that array.

Share This Page