表達式
|
描述
|
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[選擇屬性]
|
路徑表達式
|
結果
|
bookstore
|
Selects all the child nodes of the bookstore element[選擇全部bookstore元素的子節]
|
/bookstore
|
Selects the root element bookstore
Note: If the path starts with a slash ( / ) it always represents an absolute path to an element!
[選擇了bookstore的根元素。注意:若是路徑的開始爲(/)那此路徑必定是到該元素的絕對路徑]
|
bookstore/book
|
Selects all book elements that are children of bookstore[選擇了全部在bookstore的子元素book元素所包含的全部元素(其實就爲bookstore裏book元素所包含的元素)]
|
//book
|
Selects all book elements no matter where they are in the document[選擇全部爲book元素的內容而無論book元素處於何處(有不一樣的父也不要緊)]
|
bookstore//book
|
Selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element[在bookstore元素內全部含有book元素的元素內容(只要book元素的祖元素爲bookstore元素那都符合條件)]
|
//@lang
|
Selects all attributes that are named lang[選擇全部屬性名爲lang的屬性]
|
路徑表達式
|
結果
|
/bookstore/book[1]
|
Selects the first book element that is the child of the bookstore element[選擇了bookstore裏的第一個book元素]
|
/bookstore/book[last()]
|
Selects the last book element that is the child of the bookstore element[選擇bookstore裏最後一個book元素]
|
/bookstore/book[last()-1]
|
Selects the last but one book element that is the child of the bookstore element[bookstore中倒數第二個book元素]
|
/bookstore/book[position()<3]
|
Selects the first two book elements that are children of the bookstore element[在bookstore中前兩個book元素]
|
//title[@lang]
|
Selects all the title elements that have an attribute named lang[選擇全部含有lang屬性的title元素]
|
//title[@lang='eng']
|
Selects all the title elements that have an attribute named lang with a value of 'eng'[選擇全部含有lang屬性而且值爲eng的title元素]
|
/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的book元素]
|
/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[選擇bookstore中book的子元素title,而且其兄弟元素price的內容得大於35.00]
|
通配符
|
描述
|
*
|
Matches any element node[相吻合的全部元素節]
|
@*
|
Matches any attribute node[相吻合的全部屬性節]
|
node()
|
Matches any node of any kind[吻合任何類型的節]
|
路徑表達式
|
結果
|
/bookstore/*
|
Selects all the child nodes of the bookstore element[選擇全部bookstore的子節]
|
//*
|
Selects all elements in the document[選擇全部文檔中的元素]
|
//title[@*]
|
Selects all title elements which have any attribute[選擇元素爲title而且其含有屬性]
|
路徑表達
|
結果
|
//book/title | //book/price
|
Selects all the title AND price elements of all book elements[選擇全部book裏title和price元素]
|
//title | //price
|
Selects all the title AND price elements in the document[選擇全部title和price元素]
|
/bookstore/book/title | //price
|
Selects all the title elements of the book element of the bookstore element AND all the price elements in the document[選擇全部book裏的title元素和全部price元素]
|
軸名
|
結果
|
ancestor
|
Selects all ancestors (parent, grandparent, etc.) of the current node[選擇了當前節的全部祖(父,祖父,等等)]
|
ancestor-or-self
|
Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself[選擇當前節的全部祖而且還有當前節本身]
|
attribute
|
Selects all attributes of the current node[選擇全部當前節的屬性]
|
child
|
Selects all children of the current node[選擇全部當前節的子]
|
descendant
|
Selects all descendants (children, grandchildren, etc.) of the current node[選擇全部當前節的孫(子,孫子,等等)]
|
descendant-or-self
|
Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself[選擇當前節的全部孫以及它自己]
|
following
|
Selects everything in the document after the closing tag of the current node[選擇全部在關閉當前節標籤後的全部內容]
|
following-sibling
|
Selects all siblings after the current node[選擇全部當前節後的兄]
|
namespace
|
Selects all namespace nodes of the current node[選擇全部當前節的命名空間]
|
parent
|
Selects the parent of the current node[選擇當前節的父]
|
preceding
|
Selects everything in the document that is before the start tag of the current node[選擇當前節以前的全部內容]
|
preceding-sibling
|
Selects all siblings before the current node[選擇全部當前節以前的兄]
|
self
|
Selects the current node[選擇當前節]
|
Example
|
結果
|
child::book
|
Selects all book nodes that are children of the current node[選擇當前節點下全部爲book的子節點]
|
attribute::lang
|
Selects the lang attribute of the current node[選擇當前節點下全部屬性爲lang的內容]
|
child::*
|
Selects all children of the current node[選擇當前節下全部的子節]
|
attribute::*
|
Selects all attributes of the current node[選擇當前節全部的屬性]
|
child::text()
|
Selects all text child nodes of the current node[選擇當前節點全部子節點的文字]
|
child::node()
|
Selects all child nodes of the current node[選擇全部當前節點的子節點]
|
descendant::book
|
Selects all book descendants of the current node[選擇當前節點全部爲book的孫節點]
|
ancestor::book
|
Selects all book ancestors of the current node[選擇全部當前祖節點爲book的節點]
|
ancestor-or-self::book
|
Selects all book ancestors of the current node - and the current as well if it is a book node[當前節點和其祖節點爲book的節點]
|
child::*/child::price
|
Selects all price grandchildren of the current node[當前節點全部含price的孫子節點]
|
Operator
|
Description
|
Example
|
Return value
|
|
|
Computes two node-sets
|
//book | //cd
|
Returns a node-set with all book and cd elements
|
+
|
Addition
|
6 + 4
|
10
|
-
|
Subtraction
|
6 - 4
|
2
|
*
|
Multiplication
|
6 * 4
|
24
|
div
|
Division
|
8 div 4
|
2
|
=
|
Equal
|
price=9.80
|
true if price is 9.80 false if price is 9.90 |
!=
|
Not equal
|
price!=9.80
|
true if price is 9.90 false if price is 9.80 |
<
|
Less than
|
price<9.80
|
true if price is 9.00 false if price is 9.80 |
<=
|
Less than or equal to
|
price<=9.80
|
true if price is 9.00 false if price is 9.90 |
>
|
Greater than
|
price>9.80
|
true if price is 9.90 false if price is 9.80 |
>=
|
Greater than or equal to
|
price>=9.80
|
true if price is 9.90 false if price is 9.70 |
or
|
or
|
price=9.80 or price=9.70
|
true if price is 9.80 false if price is 9.50 |
and
|
and
|
price>9.00 and price<9.90
|
true if price is 9.80 false if price is 8.50 |
mod
|
Modulus (division remainder)
|
5 mod 2
|
1
|