XML DOM node tree
XML DOM treats an XML document as a node tree.
All nodes in the tree have relationships with one another.
XML DOM Node Tree
XML DOM treats an XML document as a tree structure. This tree structure is callednode tree。
All nodes can be accessed through this tree. Their contents can be modified or deleted, and new elements can be created.
This node tree shows the collection of nodes and the connections between them. The tree starts at the root node and grows branches toward text nodes at the lowest levels of the tree:

The image above represents an XML file.books.xml。
Parent nodes, child nodes, and sibling nodes.
The nodes in the node tree have hierarchical relationships with one another.
Parent nodes, child nodes, and sibling nodes are used to describe these relationships. A parent node owns child nodes, and child nodes at the same level are called siblings (brothers or sisters).
- In the node tree, the node at the top is called the root node.
- Every node except the root node has a parent node.
- A node can have any number of child nodes.
- A leaf is a node with no child nodes.
- Sibling nodes are nodes that have the same parent node.
The image below shows a portion of the node tree and the relationships between nodes:

Because XML data is structured in the form of a tree, it can be traversed without knowing the exact structure of the tree or the types of data it contains.
You will learn more about traversing the node tree in a later chapter of this tutorial.
First child - last child
See the following XML fragment:
In the XML above, the <title> element is the first child of the <book> element, and the <price> element is the last child of the <book> element.
In addition, the <book> element is the parent node of the <title>, <author>, <year>, and <price> elements.
other extensions