- 浏览: 213243 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
strong8808:
activemq5.8.0 客户端,服务端启动序列图 -
xurichusheng:
第一题,如果使用 not exists 的话,可以改成:SEL ...
SQL笔试题 -
dingjun1:
cuisuqiang 写道如何解决呢?我的是对了也照样缓存增加 ...
事务未正确关闭引起的HIBERNATE SESSION不能正确关闭 -
dingjun1:
aijezdm915 写道lz ,我也是在写项目描述是犯愁,能 ...
如果在简历中描述项目 -
aijezdm915:
lz ,我也是在写项目描述是犯愁,能否给个你的简历demo,我 ...
如果在简历中描述项目
转载:http://www.w3schools.com/XPath/xpath_syntax.asp
暂时没有整理,乱,以后再整理
Selecting Nodes
/
//
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:
Expression Description
nodename Selects all child nodes of the named 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
In the table below we have listed some path expressions and the result of the expressions:
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
Predicates
Predicates are used to find a specific node or a node that contains a specific value.
Predicates are always embedded in square brackets.
In the table 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.
Note: IE5 and later has implemented that [0] should be the first node, but according to the W3C standard it should have been [1]!!
/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
Selecting Unknown Nodes
XPath wildcards can be used to select unknown XML elements.
Wildcard Description
* Matches any element node
@* Matches any attribute node
node() Matches any node of any kind
In the table below we have listed some path expressions and the result of the expressions:
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
Selecting Several Paths
By using the | operator in an XPath expression you can select several paths.
In the table below we have listed some path expressions and the result of the expressions:
Path Expression Result
//book/title | //book/price Selects all the title AND price elements of all book elements
//title | //price Selects all the title AND price elements in the document
/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
暂时没有整理,乱,以后再整理
Selecting Nodes
Selects from the root node |
Selects nodes in the document from the current node that match the selection no matter where they are |
XPath uses path expressions to select nodes in an XML document. The node is selected by following a path or steps. The most useful path expressions are listed below:
Expression Description
nodename Selects all child nodes of the named 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
In the table below we have listed some path expressions and the result of the expressions:
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
Predicates
Predicates are used to find a specific node or a node that contains a specific value.
Predicates are always embedded in square brackets.
In the table 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.
Note: IE5 and later has implemented that [0] should be the first node, but according to the W3C standard it should have been [1]!!
/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
Selecting Unknown Nodes
XPath wildcards can be used to select unknown XML elements.
Wildcard Description
* Matches any element node
@* Matches any attribute node
node() Matches any node of any kind
In the table below we have listed some path expressions and the result of the expressions:
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
Selecting Several Paths
By using the | operator in an XPath expression you can select several paths.
In the table below we have listed some path expressions and the result of the expressions:
Path Expression Result
//book/title | //book/price Selects all the title AND price elements of all book elements
//title | //price Selects all the title AND price elements in the document
/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
发表评论
-
solr/home 设置
2013-04-21 00:44 1247solr/home是solr实例化core核的依据和入口,是必 ... -
CronTrigger Tutorial
2011-02-24 18:58 914转载地址:http://www.quartz-schedule ... -
事务未正确关闭引起的HIBERNATE SESSION不能正确关闭
2010-10-30 13:46 1666问题现象: 第一 ... -
hibernate 四种抓取策略
2010-10-24 10:42 924转载:http://www.cnblogs.com ... -
cas分析
2010-05-10 13:20 1973Central Authentication Service ... -
FCKeditor2.6.5及后续版本 for PHP配置及中文上传乱码解决!
2009-12-10 13:37 1408对于Fckeditor上传中文名文件时显示乱码的问题,现公布方 ... -
jstl标签中循环map
2009-10-12 20:58 2590<% Map map = new HashMap(); ... -
log4j输出多个自定义日志文件(分离日志)
2009-06-24 11:30 2600转载: http://wangjc-opal.iteye.co ... -
错误: 必须限制口令文件读取访问
2008-10-10 17:06 3091转载:http://hi.baidu.com/lifecodi ... -
spring AOP使用结总结
2008-09-12 14:23 1108AOP使用结总结 最近需要 ... -
log4j手动加载配置文件
2008-09-10 15:26 3174PropertyConfigurator.configur ... -
spring集成hibernate使用缓存简单实例
2008-07-08 18:20 2361这部分为转载:http://www ... -
lucene应用入门1
2008-07-06 16:49 2151简单的建立索引和索引 ... -
多对多查询的条件设置和删除问题
2008-07-03 14:50 1502select 父 from 父类 父 left join 父. ... -
DOM4J学习笔记
2008-07-01 15:07 3715DOM4J简单介绍 基本使用 读取XML文档 Import o ... -
延迟初始化错误(转载)
2008-06-12 17:52 1009转载地址:http://lz726.ite ... -
UUID [转帖]
2008-05-20 15:25 921/***********本人原创,欢迎转载,转载请保留本人信息 ... -
一段简单的发送邮件代码
2008-04-28 15:57 1043package send; import java. ... -
重新学习 Hibernate fetch lazy cascade inverse[转载]
2008-04-21 11:55 1235转载:http://www.blogjava.ne ... -
HIBERNATE2 CLOB字段延迟加载办法[转载]
2008-04-18 13:49 3088[转载]http://callan.iteye.com/blo ...
相关推荐
### C#操作XML之XPath语法详解 在C#中,操作XML文档是一项常见的任务,尤其在处理配置文件、数据交换格式或集成不同系统时。为了有效地解析和查询XML数据,XPath成为了一种不可或缺的语言。本文将深入探讨XPath的...
通过这些基本语法,我们可以编写XPath表达式来精确地查找XML文档中的特定部分。例如,在给定的XML文档中,我们可以找到每个国家的名称: ```python root = ET.fromstring(xml_string) for country in root.findall...
### XPath语法详细介绍 #### XPath简介 XPath是一种用于在XML文档中进行导航的查询语言。它提供了简洁、高效的方式来定位和提取文档中的特定部分。XPath不仅仅适用于XML文档的搜索,还是XSLT(一种用于转换XML文档...
### XPath语法与函数知识点 #### XPath简介 XPath是一种在XML文档中查找信息的语言。它主要用于在XML文档中通过元素和属性进行导航。XPath是XSLT标准中的关键组成部分,同时也是XQuery和XPointer的基础。 #### ...
XPath语法中的关键概念包括: 1. **路径表达式**:如同文件系统的路径,XPath使用路径来定位节点。例如,`/bookstore/book`表示从文档根开始选取`<bookstore>`元素下的所有`<book>`元素。 2. **运算符和特殊字符**...
XPath语法生成器是一种实用工具,尤其是对于开发人员和数据分析师来说,它能简化在网页抓取过程中定位元素的工作。 这个名为“XPath Helper”的插件是专门为浏览器设计的,它使得用户能够在浏览网页时实时生成和...
Xpath语法.docx
XPath语法的核心概念包括: 1. **节点类型**:XPath中的节点包括元素(element)、属性(attribute)、文本(text)、命名空间(namespace)、处理指令(processing-instruction)、注释(comment)和文档...
XPath语法简要说明1
下面我们将详细探讨XPath语法及其在XML开发中的应用。 1. **XPath的基本概念** - **节点**:XML文档由一系列节点构成,如元素(element)、属性(attribute)、文本(text)、命名空间(namespace)、处理指令...
XPath 语法 XPath(XML Path Language)是一种用于选择 XML 文档中节点的语言。它提供了一种灵活的方式来定位和选择 XML 文档中的节点,从而能够快速地访问和处理 XML 文档。 在 XPath 中,节点是以树形结构组织的...
XPath的语法基础: 1. **节点类型**:XPath定义了七种基本的节点类型,包括元素(element)、属性(attribute)、文本(text)、命名空间(namespace)、处理指令(processing-instruction)、注释(comment)以及...
astpath:一个命令行工具用于使用XPath语法查询Python ASTs
主要给大家介绍了关于Python爬虫基础之XPath语法与lxml库用法的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
XPath语法 XPath(XML Path Language)是一种用于选择XML文档中节点或节点集的语言。它使用路径表达式来选取节点,节点是通过沿着路径(path)或者步(steps)来选取的。 XPath的基本概念: * 节点:XML文档中的...
总结来说,"xpath 语法测试"提供了一个实践XPath的环境,结合Web服务、jQuery和AJAX,展示了XPath在现代Web开发中的应用。通过这个测试,开发者可以提升XPath技能,更有效地处理XML数据,提高代码的效率和可读性。
XPath(XML Path Language)是一种在XML文档中查找信息的语言,它是W3C组织制定的一种标准查询语言,用于选取XML文档中的节点,包括元素、属性、文本等。在本项目“Xpath生成器,自动生成XPATH,C#版”中,开发者...
首先,让我们了解基本的XPath语法。XPath通过路径表达式来选取XML或HTML文档中的节点。例如,`//div[@class="slist"]/ul//a/@href`这个表达式选取了所有`class`属性值为`slist`的`div`元素下的`ul`元素内的`a`元素的...
本教程将深入探讨XPath的核心概念、语法以及实际应用。 XPath的主要目标是提供一种简洁而有效的机制,使得XML文档的某一部分可以被快速定位。在XSL(Extensible Stylesheet Language,可扩展样式表语言)中,XPath...