Comparison of XML programming interfaces: Dom sax JDOM JAXP

Source: Internet
Author: User
Tags xml parser
I. Dom (Document Object Model)
Defines a set of interfaces for the parsed versions of the XML document. The parser reads the entire document, constructs a memory-resident tree structure, and then the code can use the DOM interface to operate on this tree structure.
Advantage: the entire document tree is in the memory for ease of operation. It supports multiple features such as deletion, modification, and rescheduling;
Disadvantages: transferring the entire document to memory (including useless nodes) wastes time and space;
Usage: once the document is parsed, the data needs to be accessed multiple times;
Sufficient hardware resources (memory and CPU)

Ii. Sax
To solve Dom problems, the following occurs.
Event-driven. When the parser finds the start, end, text, start, or end of an element, it sends events and programmers write code to respond to these events and save data.
Advantage: the entire document does not need to be transferred in advance, which consumes less resources;
The code of the SAX Parser is smaller than that of the DOM parser. It is suitable for Applet and download.
Disadvantage: it is not persistent. After an event, if no data is saved, the data will be lost;
Stateless; only the text can be obtained from the event, but I do not know which element the text belongs;
Usage: applet;
Only a small amount of content in the XML document is required, and few requests are returned;
Low machine memory;

Iii. JDOM
To reduce the Dom and sax encoding volumes, JDOM appears;
Advantage: The 20-80 principle greatly reduces the amount of code
Usage: simple functions to be implemented, such as parsing and Creation
Java program
However, at the underlying layer, JDOM still uses SAX (most commonly used), Dom, and xanan

Iv. Japan
Provides unified programming interfaces for multiple XML Parser
Change the parser without changing the code
Usage: If JDOM is not used, it is generally recommended to use japx to isolate the code from the implementation details of various Resolvers. This article from: http://www.blogjava.net/nico/articles/178415.html

 

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.