0
votes

When I build my code I unable to get the data in array!

code:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
    attributes:(NSDictionary *)attributeDict {

if([elementName isEqualToString:@"catname"]) 
    appDelegate.books = [[NSMutableArray alloc] init];

else if([elementName isEqualToString:@"subcatname"]) 
           {
        aBook = [[Book alloc] init];
           }        
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {

if(!currentElementValue) 
    currentElementValue = [[NSMutableString alloc] initWithString:string];
else
  [currentElementValue appendString:string];

} - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

if([elementName isEqualToString:@"Table"]) 
  {
    [appDelegate.books addObject:aBook];
      [aBook release];
    aBook = nil;
}
else 
{
[aBook setValue:currentElementValue forKey:elementName];
  }
[currentElementValue release];
currentElementValue = nil;

}

gdb:

011-03-30 16:19:16.661 XML[5671:20b] aBook.Catname.....(null) 2011-03-30 16:19:16.661 XML[5671:20b] Processing Element: iid 2011-03-30 16:19:16.661 XML[5671:20b] Processing Value: 5 2011-03-30 16:19:16.662 XML[5671:20b] aBook.Catname.....(null) 2011-03-30 16:19:16.662 XML[5671:20b] Processing Element: subcatname 2011-03-30 16:19:16.662 XML[5671:20b] Processing Value: card5 2011-03-30 16:19:16.663 XML[5671:20b] aBook.Catname.....(null) 2011-03-30 16:19:16.663 XML[5671:20b] Processing Element: url 2011-03-30 16:19:16.663 XML[5671:20b] Processing Value: http://www.orkutgroup.com/scraps/new-year-2.jpg 2011-03-30 16:19:16.664 XML[5671:20b] aBook.Catname.....(null) 2011-03-30 16:19:16.664 XML[5671:20b] aBook..... 2011-03-30 16:19:16.665 XML[5671:20b] appDelegate.books.....( ) 2011-03-30 16:19:16.665 XML[5671:20b] aBook.Catname.....(null)

What could be the possible reason for this? Help!

1
What language, platform, IDE are you using?! You might need to show some code. - johnny
guess may be u passing nil key .....and if it is not a key value complaint try to addValue:forKey method instead - iOSPawan
actually i am trying to parse the xml file and getting the values in array!! m updating above . - Ketan Shinde

1 Answers

0
votes

u were not added iid ivar in Book class please verify