XML parsing

黄舟
Release: 2017-02-25 14:07:32
Original
1809 people have browsed it

Yesterday we talked about JSON parsing. Today we will look at XML parsing. It is also very common to need to parse xml in development. It is the same as JSON and is very similar.

XML is the abbreviation of Extensible Markup Language (Extensible Markup Language).

XML element is the basic unit of XML file content. Syntactically, an element contains a start tag, an end tag, and the data content between the tags.

The format is as follows:

Contentname>

This article Three of them will be introduced. dom4j, dom, xpath.

xml file:

XML parsing

DOM4J:

XML parsing

XML parsing

## dom4j is a very excellent Java XML API with excellent performance, powerful functions and extreme ease of use. It is the most used and is now used by many software.

XPATH:



XML parsing##XPath is the XML path language (XML Path Language), which is a language used to determine the location of certain parts of an XML document. There are very detailed documents for developers to refer to, specific node path expressions.

You need to add jaxen-1.1-beta-6.jar when using xpath analysis.

DOM:

XML parsingIt loads the entire XML document into memory as an object, no matter how big the document is. It generally handles small files.

XML parsing#There are many ways to parse XML, and the example is relatively simple. After getting the Document, you can look at the corresponding API to perform XML parsing, including parent nodes, child nodes, sibling nodes, etc. The idea is the same.

Let’s introduce the difference between Element and Node:

Element is an extension of Node, so it is more practical. For example, you can use Element to easily get the attribute getAttribute of Node. If you use Node, you can get an attribute set, and you need to search further to get the desired attribute. A node is not necessarily an element, but an element must be a node.

The above is the content of XML parsing. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
xml
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!