Xpath Nodes
# XPath Nodes
* * *
## XPath Terms
### Node
In XPath, there are seven types of nodes: elements, attributes, text, namespaces, processing instructions, comments, and document (root) nodes. An XML document is treated as a node tree. The root of the tree is called the document node or root node.
Take a look at the following XML document:
Harry Potter
J K. Rowling
2005
29.99
Examples of nodes in the above XML document:
(Document node)
J K. Rowling (Element node)
lang="en" (Attribute node)
### Atomic Value
An atomic value is a node that has no parent or child.
Examples of atomic values:
J K. Rowling
"en"
### Item
An item is either an atomic value or a node.
* * *
## Node Relationships
### Parent
Every element and attribute has a parent.
In the example below, the book element is the parent of the title, author, year, and price elements:
Harry Potter
J K. Rowling
2005
29.99
### Children
An element node can have zero, one, or more children.
In the example below, the title, author, year, and price elements are all children of the book element:
Harry Potter
J K. Rowling
2005
29.99
### Sibling
Nodes that have the same parent.
In the example below, the title, author, year, and price elements are all siblings:
Harry Potter
J K. Rowling
2005
29.99
### Ancestor
The parent, grandparent, etc., of a node.
In the example below, the ancestors of the title element are the book element and the bookstore element:
Harry Potter
J K. Rowling
2005
29.99
### Descendant
The children, grandchildren, etc., of a node.
In the example below, the descendants of the bookstore element are the book, title, author, year, and price elements:
Harry Potter
J K. Rowling
2005
29.99
AI is thinking...
[](#)(#)
(#)[](#)
[Byte Arch Coding Plan supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, official supply is stable and reliable. Β₯9.9 / month immediately open](https://maas.xfyun.cn/modelSquare?ch=maas_lm_l2E)
YouTip