GDATAXML Parsing

Discussion in 'iOS Programming' started by newtoiphonesdk, May 23, 2012.

  1. newtoiphonesdk, May 23, 2012
    Last edited: May 23, 2012

    newtoiphonesdk macrumors 6502a

    Joined:
    Jul 30, 2010
    #1
    I have got the parsing down, just having difficulties storing in an NSArray. I setup an NSLog for the NSArray and expect this:
    Code:
    TabBarSample[40191:fb03] (
            (
            "http://domain.com/image1.jpg"
     ),
    (
    "http://domain.com/image2.jpg"
    )
    )
    
    But, I get this:
    Code:
    TabBarSample[40191:fb03] (
        "http://domain.com/image1.jpg"
    )
    2012-05-23 14:35:23.408 TabBarSample[40191:fb03] (
        "http://domain.com/image2.jpg"
    )
    
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
  3. newtoiphonesdk thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #3
    Code:
     NSURL *url = [NSURL URLWithString:@"http://www.316apps.com/LakesideDocs/podcasttrial.xml"];
           
           NSData *xmlData = [[NSMutableData alloc] initWithContentsOfURL:url];
           NSError *error;
           GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData 
                                                                  options:0 error:&error];
           
           NSArray *channels = [doc.rootElement elementsForName:@"channel"];
           for (GDataXMLElement *channel in channels) {            
               
               
               NSArray *items = [channel elementsForName:@"item"];
               for (GDataXMLElement *item in items) {
                   
                   NSString *articlePoint = [item valueForChild:@"link"];
                   NSArray *linkarray = [[NSArray alloc] initWithObjects:articlePoint, nil];
    }
    }
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    I see no NSLog's in the posted code. Where do those occur?

    Which array is intended to hold the resulting list of items?

    This code:
    Code:
               for (GDataXMLElement *item in items) {
                   
                   NSString *articlePoint = [item valueForChild:@"link"];
                   NSArray *linkarray = [[NSArray alloc] initWithObjects:articlePoint, nil];
    }
    
    doesn't seem to be doing anything useful with linkarray. Worst-case (non ARC), it's leaking.

    Have you set breakpoints inside the for loops, or put NSLog's inside the loops, so you can actually see what happens as it happens, rather than just looking at the unexpected result?
     

Share This Page