XPath Terminology Notes
XPath Terminology Notes
Nodes
In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processinginstruction, comment, and document nodes. XML documents are treated as trees of nodes. he topmost element of the tree is called the root element. Look at the follo!ing XML document: "#xml version$%&.'% encoding$%I()-**+,-&%#"bookstore"book"title lang$%en%-.arr/ Potter"0title"author-1 2. 3o!ling"0author"/ear-4''+"0/ear"price-4,.,,"0price"0book"0bookstore5xample of nodes in the XML document above: "bookstore- 6root element node7 "author-1 2. 3o!ling"0author- 6element node7 lang$%en% 6attribute node7
Atomic values
8tomic values are nodes !ith no children or parent. 5xample of atomic values: 1 2. 3o!ling %en%
Items
Items are atomic values or nodes.
Relationship of Nodes
Parent
5ach element and attribute has one parent. In the follo!ing example9 the book element is the parent of the title, author, /ear, and price: "book"title-.arr/ Potter"0title"author-1 2. 3o!ling"0author"/ear-4''+"0/ear"price-4,.,,"0price"0book-
Children
5lement nodes ma/ have :ero, one or more children. In the follo!ing example9 the title, author, /ear, and price elements are all children of the book element: "book"title-.arr/ Potter"0title"author-1 2. 3o!ling"0author"/ear-4''+"0/ear"price-4,.,,"0price"0book-
Siblings
;odes that have the same parent. In the follo!ing example9 the title, author, /ear, and price elements are all siblings: "book"title-.arr/ Potter"0title"author-1 2. 3o!ling"0author"/ear-4''+"0/ear"price-4,.,,"0price"0book-
Ancestors
8 node<s parent, parent<s parent, etc. In the follo!ing example9 the ancestors of the title element are the book element and the bookstore element: "bookstore"book"title-.arr/ Potter"0title"author-1 2. 3o!ling"0author"/ear-4''+"0/ear"price-4,.,,"0price"0book"0bookstore-
Descendants
8 node<s children, children<s children, etc. In the follo!ing example9 descendants of the bookstore element are the book, title, author, /ear, and price elements: "bookstore"book"title-.arr/ Potter"0title"author-1 2. 3o!ling"0author"/ear-4''+"0/ear"price-4,.,,"0price"0book"0bookstore-