In my application am gettin开发者_如何转开发g an xml file from server and in that i have some attributes for the element.i donno how to read the attributes can anyone help me please..
NSXMLParser is a SAX-parser that is part of the iOS SDK. There are plenty of tutorials available if your google-fu is strong.
Event-Driven XML Programming Guide
In the NSXMLParser
class, you read the attributes for an element in the following event supplied by the class:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict;
The last argument attributes:(NSDictionary *)attributeDict
gives you a dictionary of the attribute-value pairs if there are any.
You can start from the following tutorial
http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/
And after that read a very good document provided by Apple to map to your requirements.
Introduction to Event-Driven XML Programming Guide for Cocoa provided by Apple.
精彩评论