The difference between XML and JSON parsing

Source: Internet
Author: User

XML and JSON are two forms of iOS parsing files, both of which are different.

1>. XML is divided into sax and Dom two ways

Sax reads the file sequentially by line, checks to find content that matches the condition, stops when the DOM is spoken, and reads all of the content into memory to create a tree structure, so the DOM is not suitable for reading large files.

The weakness of the DOM is the advantage of Sax. Sax does not have to add everything to memory, but he reads the file sequentially, so that he cannot read and modify the file arbitrarily, and the DOM tree structure can read and modify the file arbitrarily.

Sax Dom
Read files sequentially (line by row) Read the file into memory at once and create a tree-like structure
The file is read-only once and the file cannot be read arbitrarily Arbitrary access to data in the tree structure, with no limit to the number of times
The file can only be read and cannot be modified Files can be modified
Difficult to develop, write your own event controller Easy to develop

The differences between SAX and Dom are described in.

Sax is suitable for handling the following issues:

1, to deal with large-scale documents;

2. Only a portion of the folder is needed, or only specific information can be obtained from the file.

3, want to build their own object model when.

The DOM is suitable for handling the following issues:

1, the need to modify the document;

2, need to randomly access the file

    

2>. JSON is divided into XML and JSON two ways

Xml

The difference between XML and JSON parsing

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.