惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - 礼拜一

MAC实用技巧 。 工业设计的10个基本法则 Web可用性设计的247条指导方针 选中文本,变绿~ Examples of location paths using the unabbreviated syntax C# Console:利用mspaint打开图像并保存 。 15戒律 HttpWebRequest默认的只有2个并发连接限制!!!!! 获取远程XML文档 在外企工作,一些英語用法潜规则 vs2008命令窗口使用 Visual Studio 2005 中的命令窗口 Error: No such interface supported 动态加载UserControl~ - 礼拜一 - 博客园 英语常用高频语句 jQuery的一些备忘 - 礼拜一 - 博客园 XSLT模式匹配的语法 穷死了,看电子书吧~ C#里边的控件缩写大全(比较规范)
XPath表达式(缩写和详写方式)
礼拜一 · 2009-10-14 · via 博客园 - 礼拜一

Xpath是XSLT(Extensible Stylesheet Language for Transformations,可扩展样式表语言)用到的表达式语法,用于定位XSLT文档中元素的位置。

Xpath定位寻址有两种语法:一种未经缩写的语法和一种缩写的语法。未经缩写的语法可以很清晰的表达出定位路径的含义,对于开始阶段学习理解一些概念非常有帮助。大多数开发人员都使用缩写的语法,这样开发效率更高。

一个定位步骤包含3个部分:轴(axis)、节点测试和谓词(predicate).轴和节点测试通过一个双冒号(::)来分开,他们都是必须 的。而谓词可选的,如果指定了谓词,那么它就必须紧接着节点测试,并且由中括号([])括起来。定位路径中的每一个定位步骤都是由一个斜杠(/)分开的。 如果节点的查找开始于根节点(绝对路径),第一个定位步骤也开始于一个斜杠。

下面写出一些常用的Xpath语法:

1.       含义:选择文档的根
未缩写的语法:/
缩写的语法:/

2.       含义:选择当前节点的子节点中的所有para元素节点
未缩写的语法:child::para
缩写的语法:    para

3.       含义:选择根节点中的子节点的所有para元素节点(注意与上一个例子的区别)
未缩写的语法:/child::para
缩写的语法:    /para

4.       含义:选择当前节点的后代节点中的所有para元素节点
未缩写的语法:descendant::para
缩写的语法:    .//para

5.       含义:选择根节点的后代节点中所有para元素节点(注意与上一个例子的区别)
未缩写的语法:/descendant::para
缩写的语法:    //para

6.       含义:选择当前节点的所有id属性
未缩写的语法:attribute::id
缩写的语法:    @para

7.       含义:选择当前节点的所有属性
未缩写的语法:attribute::*
缩写的语法:    @*

8.       含义:选择当前节点的子节点中的第五个chapter元素节点
未缩写的语法:child::chapter[position()=5]
缩写的语法:    chapter[5]

9.       含义:选择当前节点的子节点中id值为this-one的所有chapter元素节点
未缩写的语法:child::chapter[attribute::id=”this-one”]
缩写的语法:    chapter[@id=”this-one”]

10.   含义:选择属性值不为y的所有chapter元素节点
未缩写的语法:child::chapter[not(attribute::include=”y”)]
缩写的语法:    chapter[@include =”y”]

11.   含义:选择根节点中的后代中的所有文本节点(也就是文档中所有的文本节点)
未缩写的语法:/descendant::text()
缩写的语法:    //text()

12.   含义:选择当前节点的子节点中的num属性值为1,draft属性值为y的所有part节点
未缩写的语法:child::part[attribute::num=”1”] [attribute::draft=”y”]
缩写的语法:    chapter[@num =”1”] [@draft =”y”]

13.   含义:选择当前节点的父节点,如果该父节点由include属性且值为y
未缩写的语法:parent::node()[attribute::include=”y”] 
缩写的语法:    .. [@include =”y”]

14.   含义:选择同时具有id属性和include属性的所有chapter元素节点(不管属性值是什么)
未缩写的语法:/descendant::chapter[attribute::id and attribute::include] 
缩写的语法:    //chapter[@id and @include]