XPath-Knoten
- Previous Page Einführung in XPath
- Next Page XPath-Syntax
In XPath gibt es sieben Arten von Knoten: Element, Eigenschaft, Text, Namensraum, Verarbeitungsinstruktion, Kommentar und Dokumentknoten (oder auch Wurzelknoten).
XPath-Begriffe
Knoten (Node)
In XPath gibt es sieben Arten von Knoten: Element, Eigenschaft, Text, Namensraum, Verarbeitungsinstruktion, Kommentar und Dokument (Wurzelknoten). Ein XML-Dokument wird als Knotenbaum behandelt. Der Wurzelknoten wird als Dokumentknoten oder Wurzelknoten bezeichnet.
Sehen Sie sich das folgende XML-Dokument an:
<?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
Beispiel für Knoten im obigen XML-Dokument:
<bookstore> (Dokumentknoten) <author>J K. Rowling</author> (Elementknoten) lang="en" (Eigenschaftsknoten)
Basiselement (oder auch Atomwert)
Basiselemente sind Knoten ohne Vater oder Kinder.
Beispiel für Basiselemente:
J K. Rowling "en"
Projekt (Item)
Ein Projekt ist ein Basiselement oder ein Knoten.
Knotenverhältnisse
Vater (Parent)
Jedes Element und jede Eigenschaft hat einen Vater.
Im folgenden Beispiel ist das book-Element der Vater von title, author, year und price-Elementen:
<book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
Kind (Children)
Ein Element kann null, einen oder mehrere Kinder haben.
Im folgenden Beispiel sind title, author, year und price-Elemente die Kinder des book-Elements:
<book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
Cousin (Sibling)
Knoten mit demselben Vater
Im folgenden Beispiel sind title, author, year und price-Elemente Cousins:
<book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
Vorfahr (Ancestor)
der Vater, der Großvater, usw. eines Knotens.
Im folgenden Beispiel sind die Vorfahren des title-Elements die Elemente book und bookstore:
<bookstore> <book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
Nachkommen (Descendant)
der Sohn, der Enkel, usw. eines Knotens.
Im folgenden Beispiel sind die Nachkommen von bookstore die Elemente book, title, author, year und price:
<bookstore> <book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> </bookstore>
- Previous Page Einführung in XPath
- Next Page XPath-Syntax