XPath Syntax
|
XML Weg-Sprache verwendet eine feststellende Darstellung anstatt ein Verfahrens. Jeder Ausdruck entwickelte sich durch diese Darstellung beschreibt die Arten von Nullpunkten zum Gleichen, das auf dem hierarchischen Verh�ltnis zwischen den Nullpunkten basierte. Z.B. finden die Ausdruck �Buch-/Autoren� Mittel das Autor Element enthalten im Buchelement.
|
XML Beispiel
|
Ein XML Dokument wird unten gegeben.
|
<?xml version="1.0" encoding="ISO-8859-1"?><bookstore><book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book><book>
<title lang="eng">Learning XML</title>
<price>39.95</price>
</book></bookstore>
|
Vorw�hlen von Nullpunkten
|
Nullpunkte XPath Gebrauch-Wegausdr�cke vorw�hlen. Der Nullpunkt wird vorgew�hlt, indem man einem Weg folgt. Die n�tzlichsten Wegausdr�cke sind: -
|
Expression |
Description |
nodename |
Selects all child nodes of the node |
/ |
Selects from the root node |
// |
Selects nodes in the document from the current node
that match the selection no matter where they are |
. |
Selects the current node |
.. |
Selects the parent of the current node |
@ |
Selects attributes |
Beispiel
|
Die Tabelle, die unten haben wir gegeben wird, einige Wegausdr�cke und das Resultat der Ausdr�cke verzeichnet:
|
Path Expression |
Result |
bookstore |
Selects all the child nodes of the bookstore element |
/bookstore |
Selects the root element bookstore
Note: If the path starts with a slash ( / ) it always
represents an absolute path to an element! |
bookstore/book |
Selects all book elements that are children of
bookstore |
//book |
Selects all book elements no matter where they are in
the document |
bookstore//book |
Selects all book elements that are descendant of the
bookstore element, no matter where they are under the bookstore element |
//@lang |
Selects all attributes that are named lang |
Pr�dikate
|
Pr�dikate werden verwendet, um einen spezifischen Nullpunkt zu finden, der einen Wert enth�lt. Pr�dikate werden immer in den eckigen Klammern eingebettet.
|
Example
|
Table given below we have listed some path expressions with predicates and
the result of the expressions:
|
Path Expression |
Result |
/bookstore/book[1] |
Selects the first book element that is the child of the
bookstore element |
/bookstore/book[last()] |
Selects the last book element that is the child of the
bookstore element |
/bookstore/book[last()-1] |
Selects the last but one book element that is the child
of the bookstore element |
/bookstore/book[position()<3] |
Selects the first two book elements that are children
of the bookstore element |
//title[@lang] |
Selects all the title elements that have an attribute
named lang |
//title[@lang='eng'] |
Selects all the title elements that have an attribute
named lang with a value of 'eng' |
/bookstore/book[price>35.00] |
Selects all the book elements of the bookstore element
that have a price element with a value greater than 35.00 |
/bookstore/book[price>35.00]/title |
Selects all the title elements of the book elements of
the bookstore element that have a price element with a value greater
than 35.00 |
Wie wir unbekannte Nullpunkte vorw�hlend?
|
Wildcards k�nnen benutzt werden, um unbekannte XML Elemente vorzuw�hlen.
|
Wildcard |
Description |
* |
Matches any element node |
@* |
Matches any attribute node |
node() |
Matches any node of any kind |
Beispiel
|
Die Tabelle, die unten haben wir gegeben wird, einige Wegausdr�cke und das Resultat der Ausdr�cke verzeichnet:
|
Path Expression |
Result |
/bookstore/* |
Selects all the child nodes of the bookstore element |
//* |
Selects all elements in the document |
//title[@*] |
Selects all title elements which have any attribute |
|
|
Keywords: XPath Syntax,
xpath query syntax,
xsl syntax,
xpath vb net,
xslt syntax,
asp net xpath,
xpath starts with,
xquery syntax,
vb net syntax,
xpath case insensitive,
asp net syntax,
xpath reference,
xpath tutorial,
xpath examples,
xml syntax,
xpath namespace,
xpath expressions,
xpath c#,
xpath namespaces,
xpath xml,
cdata syntax,
xpath functions,
selectsinglenode xpath,
xpath example,
c# syntax,
xsl xpath,
xpath query,
dtd syntax,
xpath attribute,
xpath contains,
xpath xslt,
xpath xmlns,
xquery xpath,
xpath expression,
javascript xpath,
xpath sort,
stylesheet syntax,
xpath selectnodes,
xpath attributes,
xpath name,
xpath queries,
xpath dom4j,
xhtml syntax,
xpath html,
xpath cdata,
xsd syntax,
xpath predicates,
xpath w3c,
css syntax,
html syntax,
xpath count,
xpath text,
xpath axis,
xmldocument xpath,
uri syntax,
xpath or,
xpath xalan,
javascript syntax,
xpath document,
jdom xpath,
xpath perl,
xpath position,
xpath predicate,
xpath substring,
xpath sample,
xpath sql,
namespace syntax,
examples syntax,
perl syntax,
msxml xpath
|