Json,xml,html of three data formats

Source: Internet
Author: User

JSON, XML, HTML

The XML parsing is as follows:

1. DOM: parsing based on XML document tree structure

The parser reads the entire document and then constructs a tree structure that resides in memory, and the code can then manipulate the tree structure using the DOM interface. Advantages: The entire document tree in memory, easy to operate, support delete, modify, rearrange and other functions; disadvantage: The entire document into memory (including useless nodes), waste time and space; Use cases: Once the document is parsed, the data must be accessed multiple times, and the hardware resources are sufficient (memory, CPU).

2. SAX: Parsing based on event flow

Sax has emerged to solve the DOM problem. SAX, event-driven. When the parser discovers the start of an element, the end of an element, text, the beginning or end of a document, and so on, the programmer writes the code that responds to these events and saves the data. Pros: No need to transfer the entire document in advance, consume less resources, SAX parser code is smaller than DOM parser code, suitable for applets, download. Cons: not persistent; After the event, if the data is not saved, then the data is lost, stateless, only the text can be obtained from the event, but the text is not known which element; use case: Applet; only a small amount of XML documents, little back access, less machine memory;

3. JDOM: Based on the tree structure, it uses pure Java technology to parse, generate, serialize and manipulate XML documents. (http://jdom.org)

Directly for Java programming services. It leverages the many features of the more powerful Java language (method overloading, collection concepts, and so on) to effectively combine the functionality of Sax and DOM.

New API functions for reading, writing, and manipulating XML in the Java language. These API functions are optimized for immediate, simple, and efficient conditions.

4. Xmlpull: Stream-based operation file

Similar to sax, is a stream-based action file, which then callbacks the developer's handlers based on the node event. Because it is stream-based processing, both Xmlpull and sax conserve memory resources and do not show all nodes in memory as the DOM does in the form of an oak. But Xmlpull is more concise than sax and does not need to scan the entire stream!

Json,xml,html of three data formats

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.