iOS GDATAXML Parsing

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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"
)
 
Last edited:

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
Post the code that builds the array.
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];
}
}
 
Comment

chown33

Moderator
Staff member
Aug 9, 2009
8,670
4,939
vertical
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?
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.