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

推荐订阅源

Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
V
V2EX - 技术
S
Secure Thoughts
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
S
Securelist
S
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
Recent Commits to openclaw:main
Recent Commits to openclaw:main
G
GRAHAM CLULEY
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
Intezer
Google Online Security Blog
Google Online Security Blog
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Webroot Blog
Webroot Blog
Jina AI
Jina AI
Engineering at Meta
Engineering at Meta
P
Proofpoint News Feed
The Cloudflare Blog
I
InfoQ
L
LangChain Blog
U
Unit 42
P
Proofpoint News Feed
S
Schneier on Security
S
Security Affairs
Y
Y Combinator Blog
T
Tenable Blog
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
量子位
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
博客园 - 聂微东
D
Darknet – Hacking Tools, Hacker News & Cyber Security
GbyAI
GbyAI
AWS News Blog
AWS News Blog

博客园 - Scott Xu(南方小鬼)

C#发现之旅第一讲 C#-XML开发 XPath Operators Basic XPath Axes Basic XPath Syntax Basic XSLT Basic 深入浅出之正则表达式(二) 深入浅出之正则表达式(一) 通过Microsoft.Feeds获取feeds My Best Loves C#(3.0) 深入浅出系列之相关概念 C#(3.0) 深入浅出系列 Expression Studio 2.0 中文版发布了 一定能影响你的简单十句话 众说不一,“八零”后程序员到底怎么了? SQL Server 2005 实用例子 你最应该雇佣的程序员的十个特征 多个检索页面,分析,Silverlight绘图 .net component 开发系列1(学习) C# 中的设计模式3:Abstract Factory(学习笔记)
XPath Basic
Scott Xu(南方小鬼) · 2008-08-31 · via 博客园 - Scott Xu(南方小鬼)

什么是XPath?

  • XPath is a syntax(语法) for defining parts of an XML document
  • XPath uses path expressions(路径表达式) to navigate(导航,定位) in XML documents
  • XPath contains a library of standard functions (包含一些标准函数库)
  • XPath is a major element in XSLT (XSLT的主要构成部份)
  • XPath is a W3C Standard (W3C的一个标准)

XPath Path Expressions(路径表达式)

XPath uses path expressions to select nodes(节点) or node-sets(节点集) in an XML document. These path expressions look very much like the expressions you see when you work with a traditional computer file system.

XPath通过路径表达式来选择XML文档中的节点或节点集,这些表达式很像那些传统的电脑文件系统的表达式.

XPath Standard Functions(标准函数)

XPath includes over 100 built-in functions. There are functions for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, and more.

XPath 包含100多个内建函数,这些函数可以返回字符串值,数值,日期和时间的比较值,节点和QName操作,因果关系操作,布尔值,还有其它等.

XPath is Used in XSLT

XPath is a major element in the XSLT standard. Without XPath knowledge you will not be able to create XSLT documents.

没有XPath知识你将不能创建有效的,灵活的XSLT文档

XQuery and XPointer are both built on XPath expressions. XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators.

XQuery 1.0 和 XPath 2.0有共同的数据模式,支持相同的函数和操作

XPath is a W3C Standard

XPath became a W3C Recommendation 16. November 1999.

XPath was designed to be used by XSLT, XPointer and other XML parsing software.

XPath Terminology术语

In XPath, there are seven kinds of nodes(七种节点): element, attribute, text, namespace, processing-instruction, comment, and document (root) nodes.

在 XPath中,共有七种节点:元素,属性,文本,命名空间,处理指令,注释和文档根节点.

看下面这个例子:

<?xml version="1.0" encoding="iso-8859-1"?>
<bookstore> <!--document node-->
  <book> <!--element node-->
    <title lang="en">Harry Potter</title> <!--lang="en"  attribute node)-->
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
</bookstore>

Atomic values(原子值)

Atomic values are nodes with no children or parent.

原子值是没有子节点和父节点的节点,如上例中的J K. Rowling、”en”。

Items

Items are atomic values or nodes.

Relationship of Nodes节点间关系

Parent父

Each element and attribute has one parent.每个元素和属性只有一个父节点

In the following example; the book element is the parent of the title, author, year, and price:

下例中book元素是title, author, year, 和 price的父节点:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

Children子

Element nodes may have zero, one or more children.元素的节点可以是零个,一个或多个

In the following example; the title, author, year, and price elements are all children of the book element:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

Siblings同胞,同科,平行

Nodes that have the same parent.具有相同父节点的节点

In the following example; the title, author, year, and price elements are all siblings:下例中,title, author, year, 和 price 元素都是同科

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

Ancestors祖先,根

A node's parent, parent's parent, etc.一个节点的父节点,父节点的父节点

In the following example; the ancestors of the title element are the book element and the bookstore element:

下例中,title元素的根是book和bookstore元素

<bookstore>
  <book>
    <title>Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
</bookstore>

Descendants胄

A node's children, children's children, etc.一个节点的子节点,子节点的子节点

In the following example; descendants of the bookstore element are the book, title, author, year, and price elements:

下例中,bookstore元素的胄是book,title,author,year和price元素

<bookstore>
  <book>
    <title>Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>
</bookstore>