xml parsing in xcode with a large xml file

ckajembrakunet

New Member
I am having an xml file which is like:\[code\]<FarmGates> <FarmGate id="1"> <name>hello</name> <address>abcd</address> <region>Huon Valley</region> <fruits> <fruit>Cherries</fruit> <fruit>Apple</fruit> </fruits> <services> <service>NA</service> </services> <latitude>-43.04964</latitude> <longitude>147.03903</longitude> <description>abc</description> <open>Open daily except Christmas and Boxing Day.</open> <contact>Contact 03 6264 1474</contact> <images> <image>a1.jpg</image> <image>b1.jpg</image> <image>c1.jpg</image> </images> </FarmGate>\[/code\]and many such tags in between... I want to get the data from this file by parsing. Methods which I am using are as follows:\[code\]- (void)parser: (NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ if(![elementName compare:@"FarmGate"]) { currentAttribute = [NSMutableString string]; currentAttribute = [attributeDict valueForKey:@"id"]; }}- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ if(![elementName compare:@"FarmGate"]) { NSLog(@"my title is %@", currentAttribute); }}\[/code\]I am only getting value of id in dictionary if I am writing any other key say name, I am getting null value. Can any one please suggest were I am lacking behind...
 
Back
Top