Implementation and differences between the JSON data types and XML data types accessed by iOS-network

Source: Internet
Author: User

A. [] indicates an array

B. {} indicates the relationship between the dictionary and the object model.

C. There are many applications. Basically, the main data transmitted by mobile development is JSON.

D.

 

 

         

To use JSON, obtain data from the network and then use:

 

[NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingAllowFragments error: nil];

Network data can be deserialized into a dictionary or array. The specific conversion type is shown in the outmost square brackets of JSON.

 

 

* XML

A. Big, difficult to parse

B. Difficult parsing steps and low efficiency

C. View XML directly to facilitate data display

 


XML parsing needs

NSXMLParser * parser = [[NSXMLParser alloc] initWithData: data];

Parser. delegate = self;

[Parser parse];

========================================================== ======================================

/**

-(Void) parserDidStartDocument :( NSXMLParser *) parser

 

-(Void) parser :( NSXMLParser *) parser didStartElement :( NSString *) elementName namespaceURI :( NSString *) namespaceURI qualifiedName :( NSString *) qName attributes :( NSDictionary *) attributeDict

 

-(Void) parser :( NSXMLParser *) parser foundCharacters :( NSString *) string

 

-(Void) parser :( NSXMLParser *) parser didEndElement :( NSString *) elementName namespaceURI :( NSString *) namespaceURI qualifiedName :( NSString *) qName

 

-(Void) parserDidEndDocument :( NSXMLParser *) parser

 

-(Void) parser :( NSXMLParser *) parser parseerroccurred :( NSError *) parseError

 

Clear Saup

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.