XML Parsing help please

Discussion in 'iOS Programming' started by vamsi.ac, Sep 22, 2009.

  1. vamsi.ac macrumors newbie

    Joined:
    Sep 22, 2009
    #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
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    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'?
     
  3. vamsi.ac thread starter macrumors newbie

    Joined:
    Sep 22, 2009
    #3
    program terminating due to uncaught exception

    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
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Did you address the issues I brought up in my first post?
     

Share This Page