用XPath处理XML时遇到的选取节点的方法
2011-11-25 16:01
309 查看
Here are some examples of location paths using abbreviated syntax:
paraselects the
paraelement children of the context node
*selects all element children of the context node
text()selects all text node children of the context node
@nameselects the
nameattribute of the context node
@*selects all the attributes of the context node
para[1]selects the first
parachild of the context node
para[last()]selects the last
parachild of the context node
*/paraselects all
paragrandchildren of the context node
/doc/chapter[5]/section[2]selects the second
sectionof the fifth
chapterof the
doc
chapter//paraselects the
paraelement descendants of the
chapterelement children of the context node
//paraselects all the
paradescendants of the document root and thus selects all
paraelements in the same document as the context node
//olist/itemselects all the
itemelements in the same document as the context node that have an
olistparent
.selects the context node
.//paraselects the
paraelement descendants of the context node
..selects the parent of the context node
../@langselects the
langattribute of the parent of the context node
para[@type="warning"]selects all
parachildren of the context node that have a
typeattribute with value
warning
para[@type="warning"][5]selects the fifth
parachild of the context node that has a
typeattribute with value
warning
para[5][@type="warning"]selects the fifth
parachild of the context node if that child has a
typeattribute with value
warning
chapter[title="Introduction"]selects the
chapterchildren of the context node that have one or more
titlechildren with string-value equal to
Introduction
chapter[title]selects the
chapterchildren of the context node that have one or more
titlechildren
employee[@secretary and @assistant]selects all the
employeechildren of the context node that have both a
secretaryattribute and an
assistantattribute
相关文章推荐
- DOM4J处理XML方法记录,附XPATH写法
- DOM4J处理XML方法记录,附XPATH写法
- .net中使用XPath语言在xml中判断是否存在节点值的方法
- XPath 使用路径表达式来选取 XML 文档中的节点或节点集
- 遇到XML-GB2312网页编码的处理方法
- XML:XPath路径定义选取节点 XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。 下面列出了最有用的路径表达式: 表达式 描述 nodename
- Python+Selenium xpath 定位遇到相同元素时的解决方法父节点找子节点
- XPath 使用路径表达式来选取 XML 文档中的节点或节点集
- Xml中SelectSingleNode方法,xpath查找某节点用法
- XML节点存在namespace(xmlns)的时候xpath不能正常工作
- C#通过xpath查找xml指定元素的方法
- xpath相对当前节点定位方法总结
- R语言遇到bug的处理方法
- 在Dom4j中使用Xpath搜索xml的元素节点
- dom4j的xpath各种方法查找节点
- C# 字符串,数组,日期常遇到的处理方法(持续更新)
- dom4j的xpath查找xml的指定节点
- Xml中SelectSingleNode方法中的xpath用法[转]
- 用 query 方法 获得xml 节点的值
- 通过Fuel 7.0安装OpenStack Kilo遇到的问题及处理的方法