XPath(5) Use axis, nodetest and predicate to define path expression
来源:互联网 发布:捷西网络官网地址 编辑:程序博客网 时间:2024/06/10 05:34
XPath1.0 uses path expressions to select nodes or node-sets in an XML document.
This is the most commonly used technique for xPath. path expression can appear in theselectattribute ortestattribute in the if statement
Syntax:
axis::nodeTest[optional predicate]
example:
/bookstore/book[position()<3]
Selects the first two book elements that are children of the bookstore element
axis
There are 13 types of axis:
- child axis - the default axis
- attribute axis - attribute::FName and @FName are equivalent.
- ancestor axis
- ancestor-or-self axis
- descendant axis
- descendant-or-self axis - descendant-or-self::c and a//c are equivalent
- following axis
- following-sibling axis
- namespace axis (not used in XQuery, and deprecated in XPath 2.0)
- parent axis - parent:: and .. are equivalent
- preceding axis
- preceding-sibling axis
- self axis - self:: and . are equivalent
The following picture clarify the relationship of axis
Node Test
Specifies the initial set of nodes.
Could be
Node Name Test
- * or @*
- QName (qualified name)
- NCName (Named Characters Name) or reqularly named node
- id(id)
Node Type Test
- comment().
- text().
- processing-instruction().
- processing-instruction("target").
- node(). Any node except for attribute nodes and the root node.
Predicate
OPTIONAL, specifies conditions that have to be met by the node among the node set.
CAN BE NESTED axis::nodeTest[optional predicate[optional predicate]]
Can have more than one predicate axis::nodeTest[optional predicate][optional predicate]
Predicates can contain operators and functions!
In fact, predicates can be used to filter any kind of sequence.
More on xPath:
http://www.georgehernandez.com/h/xComputers/XML/XSL/XPath.asp
- XPath(5) Use axis, nodetest and predicate to define path expression
- c# Use a lambda expression to define an event handler
- xpath and regular expression
- Define and use ripple
- Use data define file and colmap to map different column
- How to Create and Evaluate XPath Expression in Java - Tutorial and Example
- Use regular expression to get filename from a file full path name.
- XPath中对Location Paths进行定位操作的语法--Axis和Predicate
- when to use the macro "assert(expression)"
- use regulator to test regular expression
- Use regular expression to find something
- How to use Regular Expression in LotusScript
- Use Lambda expression to iterate collection members
- Use Flex and JavaScript to get the full path of a local File
- How to use OpenCV to Access IP Cameras (eg. Axis)
- Querying XML Data Using XPATH Expression and the XML DOM
- C-Sharp function to escape single-quote on XPath expression
- How to: Use Expression Trees to Build Dynamic Queries
- c++学习11
- ubuntu 10.10 编译 PTAMM
- php图片识别
- WIN7 X64 SSDT函数获得
- irp的处理,免得忘了
- XPath(5) Use axis, nodetest and predicate to define path expression
- Windows NT 驱动程序开发人员提示 -- 应注意避免的事项
- cocos2d-x中CCSprite更换图片
- Javascirpt的strict模式
- uva 10152 - ShellSort
- 内核模式开发笔记
- 通过 FILE API 使用 JAVASCRIPT 读取文件
- 给网页加锚点
- OGRE列表