This is How I have written my code:
Code:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
currentElement = [[elementName copy] autorelease];
NSLog(currentElement);
if ([elementName isEqualToString:@"category"])
{
lbl1.text = [attributeDict valueForKey:@"name"];
NSLog([attributeDict valueForKey:@"name"]);
hello = FALSE;
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if (hello) {
[currnetCategory appendString:string];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
currentElement = [[elementName copy] autorelease];
NSLog(currentElement);
if ([elementName isEqualToString:@"categories"])
{
return;
}
else if([elementName isEqualToString:@"category"])
{
NSLog(lbl1.text);
hello = FALSE;
}
}
it is giving me the correct value for
NSLog([attributeDict valueForKey:@"name"]); in gdb.
- But at the end of xml file it was giving me error "EXC_BAD_ACCESS".