分类: Python/Ruby
2013-05-25 14:48:10
| 表达式 | 引用 |
|---|---|
|
./author |
当前上下文中的所有 |
|
author |
当前上下文中的所有 |
|
first.name |
当前上下文中的所有 |
|
/bookstore |
此文档的文档元素 ( |
|
//author |
文档中的所有 |
|
book[/bookstore/@specialty=@style] |
style 属性值等于文档根处 |
|
author/first-name |
作为 |
|
bookstore//title |
|
|
bookstore/*/title |
作为 |
|
bookstore//book/excerpt//emph |
位于 |
|
.//title |
当前上下文中一级或多级深度的所有 |
|
author/* |
作为 |
|
book/*/last-name |
作为 |
|
*/* |
当前上下文的所有孙级元素。 |
|
*[@specialty] |
具有 specialty 属性的所有元素。 |
|
@style |
当前上下文的 style 属性。 |
|
price/@exchange |
当前上下文中 |
|
price/@exchange/total |
返回空节点集,因为属性不包含元素子级。 XML 路径语言 (XPath) 语法允许使用此表达式,但是严格意义上讲无效。 |
|
book[@style] |
当前上下文的具有 style 属性的 |
|
book/@style |
当前上下文的所有 |
|
@* |
当前元素上下文的所有属性。 |
|
./first-name |
当前上下文节点中的所有 |
|
first-name |
当前上下文节点中的所有 |
|
author[1] |
当前上下文节点中的第一个 |
|
author[first-name][3] |
具有 |
|
my:book |
my 命名空间中的 |
|
my:* |
my 命名空间中的所有元素。 |
|
@my:* |
my 命名空间中的所有属性(不包括 my 命名空间中的元素的未限定属性)。 |
|
x/y[1] |
每个 |
|
x/y[position() = 1] |
每个 |
|
(x/y)[1] |
|
|
x[1]/y[2] |
第一个 |
|
book[last()] |
前上下文节点的最后一个 |
|
book/author[last()] |
前上下文节点的每个 |
|
(book/author)[last()] |
当前上下文节点的 |
|
book[excerpt] |
包含至少一个 |
|
book[excerpt]/title |
作为 |
|
book[excerpt]/author[degree] |
包含至少一个 |
|
book[author/degree] |
包含 |
|
author[degree][award] |
包含至少一个 |
|
author[degree and award] |
包含至少一个 |
|
author[(degree or award) and publication] |
包含至少一个 |
|
author[degree and not(publication)] |
包含至少一个 |
|
author[not(degree or award) and publication] |
包含至少一个 |
|
author[last-name = "Bob"] |
包含至少一个值为 Bob 的 |
|
author[last-name[1] = "Bob"] |
第一个 |
|
author[last-name [position()=1]= "Bob"] |
第一个 |
|
degree[@from != "Harvard"] |
from 属性不等于 "Harvard" 的所有 |
|
author[. = "Matthew Bob"] |
值为 Matthew Bob 的所有 |
|
author[last-name = "Bob" and ../price > 50] |
包含值为 Bob 的 |
|
book[position() <= 3] |
前三本书(1、2、3)。 |
|
author[not(last-name = "Bob")] |
不包含值为 Bob 的 |
|
author[first-name = "Bob"] |
至少有一个值为 Bob 的 |
|
author[* = "Bob"] |
所有包含任何值为 Bob 的子元素的 author 元素。 |
|
author[last-name = "Bob" and first-name = "Joe"] |
具有值为 Bob 的 |
|
price[@intl = "Canada"] |
上下文节点中 intl 属性等于 "Canada" 的所有 |
|
degree[position() < 3] |
作为上下文节点子级的前两个 |
|
p/text()[2] |
上下文节点中每个 元素的第二个文本节点。 |
|
ancestor::book[1] |
上下文节点最近的 |
|
ancestor::book[author][1] |
上下文节点最近的 |
|
ancestor::author[parent::book][1] |
当前上下文最近的 |