Hi all I am parsing my xml with libxml ,my code is as follows
-(void) grabRSSFeed:(NSString *)blogAddress {
// Initialize the blogEntries MutableArray that we declared in the header
blogEntries = [[NSMutableArray alloc] init];
// Convert the supplied URL string into a usable URL object
NSURL *url = [NSURL URLWithString: blogAddress];
// Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
// object that actually grabs and processes the RSS data
CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];
// Create a new Array object to be used with the looping of the results from the rssParser
NSArray *resultNodes = NULL;
// Set the resultNodes Array to contain an object for every instance of an node in our RSS feed
resultNodes = [rssParser nodesForXPath:@"//entry" error:nil];
// Loop through the resultNodes to access each items actual data
for (CXMLElement *resultElement in resultNodes) {
// Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries
NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
// Create a counter variable as type "int"
int counter;
// Loop through the children of the current node
for(counter = 0; counter < [resultElement childCount]; counter++) {
// Add each field to the blogItem Dictionary with the node name as key and node value as the value
[blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
}
// Add the blogItem to the global blogEntries Array so that the view can access it.
[blogEntries addObject:[blogItem copy]];
}
}
my xml is as follows − Testing 2 Long post − <p>Testing <em>long</em> <strong>post 2</strong></p> <p>Test <a href="http://www.google.com" title="GOOGLE">data</a></p> <p>more detail by pressing Add a Text</p> 2010-10-15 2010-10-15 2010-10-15 − − acer-aspire-series-wallpaper 123 2010-10-15 2010-10-15 2010-10-15 HORIZONTAL 1 Pooja gallery − /photos/medium/12535.PNG /photos/original/12535.jpg /photos/thumbnail/12535.PNG /photos/smallThumbnail/12535.PNG − 8-14-2010 12-57-57 PM 2010-10-15 2010-10-15 2010-10-15 HORIZONTAL 0 Pooja gallery − /photos/medium/12534.PNG /photos/original/12534.png /photos/thumbnail/12534.PNG /photos/smallThumbnail/12534.PNG − tag1 tag2 − Testing 1 Short post 2010-10-15 2010-10-15 2010-10-15 − Testing 1 Long post <p>Data for the first post</p> 2010-10-15 2010-10-15 2010-10-15
here it gets crash with message Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: photos)' * Call stack at first throw:
Thanks in advance I am trying this for long time ,here i dont know how to get the value of child node if someone can help me out.