hi all,
I do have an xml file like,
<posts>
< photo id="12412" private="false" >
<title>happy_diwali_diya_wallpaper</title>
<caption>Happy Diwali</caption>
<dateCreated>2010-10-14</dateCreated>
<dateLastUpdated>2010-10-14</dateLastUpdated>
<postDate>2010-10-14</postDate>
<orientation>HORIZONTAL</orientation>
<sortOrder>0</sortOrder>
<gallery id="4602">my gallery</gallery>
<photoData>
<image size="medium">/photos/medium/12412.PNG</image>
<image size="original">/photos/original/12412.jpg</image>
<image size="thumbnail">/photos/thumbnail/12412.PNG</image>
<image size="smallThumbnail">/photos/smallThumbnail/12412.PNG</image>
</photoData>
</photo>
</posts>
Edit: Here are some code,
// 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];
NSURL *url = [[NSURL alloc] initFileURLWithPath: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:@"//photo" 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;
NSLog(@"%d",[resultElement childCount]);
// Loop through the children of the current node
for(counter = 0; counter < [resultElement childCount]; counter++) {
//Here I am getting Crashed
if ([[[resultElement childAtIndex:counter] name] isEqualToString:@"photoData"]) {
NSLog(@"%@",[resultElement children]);
}
else {
// 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]];
}
in that
till the gallary tag I am able to parse the file , but I am not able to parse the < PhotoData> tag.
Can any one help me how to parse that tag, so that I can get the details of < image> tag in the same.
thanks in advance.