XPath 的意思是 XML 路径语言。它使用的一个非 XML 语法提供一种灵活地定位 XML (en-US) 文档的不同部分的方法。它同时也可以用于检测文档中某个节点是否与某个模式(pattern)匹配。

XPath 主要被用于 XSLT,也可用于定位文档元素,像类 XML 语言文档(如 HTML 和 XUL ) 通过 DOM (en-US) 定位元素一样。替代 document.getElementById 方法、 element.childNodes 属性和其他 DOM 核心特性。

XPath 使用路径标识符通过层级结构来导航 XML 文档。它使用非 XML 语法,以致于它可以被用在 URIs 和 XML 属性值上。

备注: XPath 的浏览器支持差别很大;Firefox 支持地相当不错 (尽管没有计划进一步提高支持),而其他浏览器则较小程度地实现了它。如果你需要一个兼容主流浏览器的 XPath,你可以考虑试试 js-xpathwicked-good-xpath.


在 JavaScript 中使用 XPath 的介绍

描述了 XPath 的一个非 XSLT 使用。


List and definition of the axes defined in the XPath specification. Axes are used to describe the relationships between nodes.

XPath:Functions (en-US)

List and description of the core XPath functions and XSLT-specific additions to XPath.

Transforming XML with XSLT

XSLT uses XPath to address code segments in a XML document that it wishes to transform.

XPath snippets (en-US)

JavaScript utility functions to use in your own code, based on DOM Level 3 XPath APIs.

What is XSLT?

This extensive introduction to XSLT and XPath assumes no prior knowledge of the technologies, and guides the reader through background, context, structure, concepts and introductory terminology.


JXON (lossless JavaScript XML Object Notation) is a generic name by which is defined the representation of JavaScript Objects using XML. There are some cases in which the whole content of an XML document must be read from the JavaScript interpreter (like for web-apps languages or settings XML documents, for example). In these cases JXON could represent the most practical way and a valid alternative to XPath.



Feature rich XPath generator, editor, inspector, and simple extraction tool (FireFox Add-On).


XPath panel that integrates tightly into FireBug, providing an editor and inspector (FireFox Add-On).

XMLQuire (formerly known as SketchPath)

A Graphical XPath Builder/Debugger(.NET).