Home > Web Front-end > Front-end Q&A > What is the difference between node and element in xml

What is the difference between node and element in xml

WBOY
Release: 2022-04-19 18:06:47
Original
2797 people have browsed it

The difference between node and element in xml is: Element is an element, a small-scale definition, and one of the components of the data. It must be a node containing complete information to be an element; while Node is a node. , relative to the TREE data structure, a node is not necessarily an element, and an element must be a node.

What is the difference between node and element in xml

The operating environment of this tutorial: windows10 system, xml3.0 version, Dell G3 computer.

What is the difference between node and element in xml

The difference between element (Element) and node (Node). Element is a small-scale definition and must be a node containing complete information. is an element, such as

...

. But a node is not necessarily an element, and an element must be a node.

What is node:

NODE is relative to the data structure of TREE. TREE is composed of NODE. You can refer to the tree diagram of discrete mathematics for this part.

What is element

ELEMENT is a concept in XML. is an element and is one of the components of data in XML.

The difference between Element and Node. Element is a small-scale definition. It must be a node containing complete information to be an element, such as

.... But a node is not necessarily an element, and an element must be a node.

The reason why I am confused about Element and Node is because I don’t understand the entire structure of xml. The following is a brief overview:

What is the difference between node and element in xml

As can be seen from the above picture, a The xml document consists of element nodes, attribute nodes, and text nodes. Bookstore is called a document element or root element and is also an element node.

XML DOM specifies a node like this

  • Each component in an XML document is a node.

  • The entire document is a document node, that is, the Document node. In Java, the Document interface is inherited from the Node interface, representing the entire XML document

  • Each XML tag is an element node, that is, an ELEMENT node. In Java, the Element interface inherits from the Node interface and represents an element in an XML document.

  • The text contained in the XML element is a text node, that is, a Text node. In java, the Text interface inherits from the CharacterData interface, and CharacterData inherits from the Node interface, representing the text content of Element or Attr

  • Each XML attribute is an attribute node, that is, an Attr node. In java, the Attr interface inherits from the Node interface. Comments belong to the comment node, that is, the Comment node. In java, the Comment interface inherits from the CharacterData interface, and CharacterData inherits from the Node interface

So in fact, every object in the xml document is a node. Elements must be nodes, but nodes are not necessarily elements.

Recommended learning: "nodejs video tutorial"

The above is the detailed content of What is the difference between node and element in xml. For more information, please follow other related articles on the PHP Chinese website!

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