IOS development NOTE 3: XML/JSON data parsing, iosjson

Source: Internet
Author: User

IOS development NOTE 3: XML/JSON data parsing, iosjson

This article mainly summarizes the methods used in XML/JSON data parsing in iOS development. XML data parsing mainly uses the NSXMLParser In the SAX mode and the GDataXML In the DOM mode, and the NSJSONSerialization in the json data parsing mode.

1. NSXMLParser for XML Parsing

NSXMLParser is a native XML Parsing Method for iOS. It uses the SAX Method for parsing. It is characterized by parsing each element from the root element in sequence.

Take the XML document as an example for parsing

 

(1) first, instantiate an NSXMLParser, set the proxy to listen to the parsing process, and start parsing.

Https://github.com/neonichu/GDataXML

Take the XML document used in the previous section as an example. You need to configure it before using it.

(1) set the header file path

If the outermost layer of the JSON string is neither NSArray nor NSDictionary, select NSJSONReadingAllowFragments for option.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.