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

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - 张少峰

在linuxdeepin10.12下源码安装bochs-2.4.6 设置pppoe时遇到“Oh, dear, I don't see the file '/etc/ppp/pppoe.conf' anywhere.”时的解决方法 安装ubuntu10.10时遇到ubi partman crashed,ubi-partman failed with exit code 141的解决方案 糗事的教训:做事一定要细心细心再细心 Reflector插件FileDisassembler汉化修改版 解压用Sixxpack2.2压缩过的程序,拿原始程序集 - 张少峰 - 博客园 利用网页挂马拿服务器的一种设想 第一次上首页,发一个玩具级的持久化工具~ python一些细微的东西 IndentationError: unindent does not match any outer indentation level Request的几种路径属性 一个方法返回多个值的解决方法 值类型与引用类型 用反射把程序集中一些泛型类实例化,怎么确定实例的类型? 父类实现IComparable<T>接口,子类无法使用~ [转载]谓词和操作(c#版) 静态变量的继承 XPath初学笔记(四) XPath初学笔记(二)
XPath初学笔记(三)
张少峰 · 2008-06-28 · via 博客园 - 张少峰

【本文是在阅读www.w3school.com.cn的教程时随手记下的内容,以免遗忘】

XPath Axes(坐标轴)

XML 实例文档

我们将在下面的例子中使用此 XML 文档:

<?xml version="1.0" encoding="ISO-8859-1"?> 

<bookstore> 

<book> 

<title lang="eng">Harry Potter</title> 

<price>29.99</price> 

</book> 

<book> 

<title lang="eng">Learning XML</title> 

<price>39.95</price> 

</book> 

</bookstore> 

XPath

轴可定义某个相对于当前节点的节点集。

轴名称

结果

ancestor

选取当前节点的所有先辈(父、祖父等)

ancestor-or-self

选取当前节点的所有先辈(父、祖父等)以及当前节点本身

attribute

选取当前节点的所有属性

child

选取当前节点的所有子元素。

descendant

选取当前节点的所有后代元素(子、孙等)。

descendant-or-self

选取当前节点的所有后代元素(子、孙等)以及当前节点本身。

following

选取文档中当前节点的结束标签之后的所有节点。

namespace

选取当前节点的所有命名空间节点

parent

选取当前节点的父节点。

preceding

选取文档中当前节点的开始标签之前的所有节点。

preceding-sibling

选取当前节点之前的所有同级节点。

self

选取当前节点。

位置路径表达式

位置路径可以是绝对的,也可以是相对的。

绝对路径起始于正斜杠( / ),而相对路径不会这样。在两种情况中,位置路径均包括一个或多个步,每个步均被斜杠分割:

绝对位置路径:

/step/step/...

相对位置路径:

step/step/...

每个步均根据当前节点集之中的节点来进行计算。

步(step)包括:

轴(axis

定义所选节点与当前节点之间的树关系

节点测试(node-test

识别某个轴内部的节点

零个或者更多谓语(predicate

更深入地提炼所选的节点集

步的语法:

轴名称::节点测试[谓语]

实例

例子

结果

child::book

选取所有属于当前节点的子元素的 book 节点

attribute::lang

选取当前节点的 lang 属性

child::*

选取当前节点的所有子元素

attribute::*

选取当前节点的所有属性

child::text()

选取当前节点的所有文本子节点

child::node()

选取当前节点的所有子节点

descendant::book

选取当前节点的所有 book 后代

ancestor::book

选择当前节点的所有 book 先辈

ancestor-or-self::book

选取当前节点的所有book先辈以及当前节点(假如此节点是book节点的话)

child::*/child::price

选取当前节点的所有 price 孙。