I have been trying to do XML parsing in iOS. But I was not able to parse it unfortunately.
Can you help me with this. I was using a SAX parser using NSXML.
The data is
<category>
<cat id="info" name="id1" value="val1" />
<cat id="info" name="id2" value="val2" />
</category>
How do i get the values using SAX parser? Any help would be appreciated.
Thanks
Answer–
(To get the attributes)
I used it this way (attributedict is the NSDictionary object in didStartElement method)
NSString *attr = [attributeDict valueForKey:@"name"];
if([attr isEqualToString:@"id1"])
{
NSLog("%@", [attributeDict valueForKey:@"value"]);
}
you need to init an NSXML instance with Data then use the parse method. You need to set up a NSXMLParserDelegate protocol, then using the following methods, you’ll be able to retrieve information :
You should read the apple documentation about it :
NSXMLParser
NSXMLParserDelegate Protocol
You’ll find Apple examples in the links.