Two ways to parse XML the difference between DOM and sax

Source: Internet
Author: User
Tags object model
Dom and Sax are the two main APIs for manipulating XML documents in an application, which are explained as follows: DOM, the Document object model, and Chinese is called the documentation objects. The DOM is the standard document object model defined by the consortium and is a model that is independent of the operating system and programming language for memory storage and operation of hierarchical documents. When parsing an XML document according to the DOM model, a corresponding DOM tree is constructed in memory that can be used for traversal between different nodes. However, you must first complete the construction of the DOM tree before traversing. Therefore, the processing of large-scale XML documents is very memory-intensive, more resources. In particular, it is inefficient to manipulate only a small portion of the document. SAX, the short name of the simple API for XML, is called the XML Simplicity application interface. It's a de facto standard. Unlike DOM, it is an event-driven model. When parsing an XML document, each time a start or end tag, or an attribute, or an instruction is encountered, the program generates an event to handle it accordingly. Therefore, you do not need to parse the entire document before you manipulate the document. In fact, parts of a document can be manipulated while parsing. As a result, sax is better suited to manipulating large documents than DOM.
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.