Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vamsi.ac

macrumors newbie
Original poster
Sep 22, 2009
6
1
hi all ,

I am following an xml parsing example from this link http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.html - iPhone SDK Articles to parse my own xml file which is in this format....
Code:
Quote:
<?xml version="1.0" encoding="UTF-8" ?>
- <Root>
- <CourseBeansList>
- <CourseBean>
<LearningId>COURSE_1</LearningId>
<LearningType>Online</LearningType>
<Title>AAO - Anatomy of the Ear</Title>
<Description>Sample AAO course used for LMS Shootout at Online Learning Conference, 2002 in Anaheim, CA</Description>
<CatalogList>Default Public CatalogOtolaryngology</CatalogList>
</CourseBean>

but i dont know how to write this part of code for my example...
Quote:

Code:
-(void)parser: (NSXMLParser *)parser didStartElementNSString *)elementName

namespaceURINSString *)namespaceURI qualifiedName: (NSString *)qualifiedName

attributes: (NSDictionary *)attributeDict {

if([elementName isEqualToString:@"Courselist"]) {

//initialize the array.

appDelegate.CourseBeansList = [[NSMutableArray alloc] init];

}

else if([elementName isEqualToString:@"Courselist"]) {

//initialize the book

aCourselist = [[Courselist alloc] init];

//extract the attribute here.

aCourselist.CourseBean = [[attributeDict objectForKey:@"id"] integerValue];

NSLog(@"Reading id value :%i", aCourselist.CourseBean);

}

NSLog(@"Processing Element: %@", elementName);

}
please help
 
First of all the
Code:
else if([elementName isEqualToString:@"Courselist"])
will never execute because it's the same condition as the first if.

Second, 'Courselist' is not even an element name given that sample XML file. Did you mean 'CourseBeansList'?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.