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