I have a web-service which provides various data I would like to display when a user makes a selection (an example could be a list of local doctors when they search for doctor).
The problem is, the web-service is older and XML-based, not JSON, and I cannot find much regarding parsing and displaying xml output in an iOS application on the internet.
All I have found is a short example of NSURL
/ NSURLConnection
, and a couple of JSON-related parsers, but I don't know how complicated starting from scratch with NSURL would become in the event of displaying large formatted ordered lists of data from a web service?
Has anyone ever had to do something like this? I am sure it's been done in the past, I would just like to see evidence of how.. Any examples of a plugin or class I could look into? Thanks!
iOS includes the NSXMLParserDelegate
then, you implement it's methods:
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//Do something when you start a new element
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
//Do something with the character inside an element
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
//Do something when you finish an element
}
it's very easy to parse the xml with just this methods
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.