Xml parsing technologies include DOM, SAX, and STAX. The difference is that DOM's performance drops significantly when processing large files. SAX is an event-driven XML parsing method. It reads XML files sequentially and does not require Load the entire file all at once.

1.DOM generates and parses XML documents
Defines a set of interfaces for the parsed version of the XML document. The parser reads in the entire document and then builds a memory-resident tree structure, and then the code can use the DOM
interface to manipulate the tree structure. Advantages: The entire document tree is in memory, easy to operate; supports multiple functions such as deletion, modification, and rearrangement; Disadvantages: Transferring the entire document into memory (including useless nodes) wastes time and space; Usage occasions: Once parsed Documents also need to access this data multiple times; hardware resources are sufficient (memory, CPU).
2.SAX generates and parses XML documents
To solve the problem of DOM, SAX appeared. SAX, event driven. When the parser finds the beginning of an element, the end of an element, the beginning or end of text, a document, etc., it sends events, and programmers write code that responds to these events and saves the data. Advantages: There is no need to load the entire document in advance, and it takes up less resources; the SAX parser code is smaller than the DOM parser code, and is suitable for Applet and download. Disadvantages: not persistent; after the event, if the data is not saved, the data is lost; stateless; only text can be obtained from the event, but it is not known which element the text belongs to; Usage occasions: Applet; only XML document A small amount of content, rarely revisited; less machine memory;
3.DOM4J generates and parses XML documents
DOM4J is a very, very excellent Java XML
API with excellent performance, powerful functions and extreme ease of use features, and it is also an open source software. Nowadays, you can see that more and more Java software is using DOM4J to read and write XML. It is particularly worth mentioning that even Sun's JAXM is also using DOM4J.
4.JDOM generates and parses XML
In order to reduce the amount of coding of DOM and SAX, JDOM appeared; advantages: 20-80 principle, greatly reducing the amount of code. Usage occasions: The functions to be implemented are simple, such as parsing, creation, etc., but at the bottom level, JDOM still uses SAX (most commonly used), DOM,
Xanan documents.
How many forms are there in XML document definition? What are the essential differences between them? What are the ways to parse XML documents?
Answer: a: two forms of dtd schema, b: essential difference: the schema itself is xml and can be parsed by an XML parser (this is also the fundamental purpose of developing schema from DTD), c: there are DOM, SAX, STAX etc.
DOM: Its performance drops significantly when processing large files. This problem is caused by the tree structure of the DOM. This structure takes up a lot of memory, and the DOM must load the entire document into the memory before parsing the file. It is suitable for
random access to XML
SAX: No Now in DOM, SAX is an event-driven XML parsing method. It reads XML files sequentially without loading the entire file all at once. When encountering an event like the beginning of the file, the end of the document, or the beginning and end of a tag, it will trigger an
event. The user can process the XML file by writing processing code in its callback event, which is suitable for sequential access to XML
The above is the detailed content of What are the differences between xml parsing technologies?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment





