PDA

View Full Version : XML Parsing help please




vamsi.ac
Sep 22, 2009, 11:12 AM
hi all ,

I am following an xml parsing example from this link http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.htm (http://www.iphonesdkarticles.com/2008/11/parsing-xml-files.html)l - iPhone SDK Articles to parse my own xml file which is in this format....

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:


-(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



dejo
Sep 22, 2009, 11:22 AM
First of all the 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'?

vamsi.ac
Sep 24, 2009, 06:56 AM
any one could please resolve my problem in this project. you can download my project from the link http://uploading.com/files/1faafca6/XML.zip/

please help me.. all i need to do is parse the xml

dejo
Sep 24, 2009, 11:42 AM
please help me.. all i need to do is parse the xml
Did you address the issues I brought up in my first post?