Дерево узлов XML DOM
- Предыдущая страница Элементы DOM
- Следующая страница Анализ DOM
XML DOM views an XML DOM document as a node tree (node-tree).
All nodes in the tree are related to each other.
Дерево узлов XML DOM
XML DOM views an XML document as a tree structure. This tree structure is calledNode tree.
All nodes can be accessed through this tree. Their content can be modified or deleted, and new elements can be created.
This node tree shows the collection of nodes and their relationships. This tree starts from the root node and then branches out to text nodes at the lowest level of the tree:

The above image represents an XML file books.xml.
Parent, child, and sibling nodes
Nodes in the node tree have a hierarchical relationship with each other.
Parent, child, and sibling nodes are used to describe this relationship. The parent node has child nodes, and child nodes at the same level are called sibling nodes (brothers or sisters).
- In the node tree, the top-level node becomes the root node
- Each node, except the root node, has a parent node
- Node can have any number of child nodes
- Листья - это узлы без подэлементов
- Элементы одного уровня - это элементы, имеющие одного родителя
Ниже приведено изображение части дерева узлов и отношений между узлами:

Поскольку данные XML структурированы в виде дерева, их можно遍ять, не зная确切ной структуры дерева и не зная типов данных, содержащихся в нем.
Вы узнаете больше о навигации по дереву узлов в более поздних главах этого руководства.
Комментарии:Родительский элемент: Parent Node, подэлемент: Children Node, элементы одного уровня: Sibling Node.
Первый подэлемент - последний подэлемент
Смотрите下面的 фрагмент XML:
<bookstore> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
В приведенном выше XML элемент <title> является первым подэлементом элемента <book>, а элемент <price> является последним подэлементом элемента <book>.
Кроме того, элемент <book> является родительским элементом для элементов <title>, <author>, <year> и <price>.
- Предыдущая страница Элементы DOM
- Следующая страница Анализ DOM