e01.org

XPath

XPath stands for XML Path Language. It uses a non-XML syntax to provide a flexible way of addressing (pointing to) different parts of an XML document. It can also be used to test addressed nodes within a document to determine whether they match a pattern or not.

XPath stands for XML Path Language. It uses a non-XML syntax to provide a flexible way of addressing (pointing to) different parts of an [XML](/docs/Web/XML/Guides/XML_introduction) document. It can also be used to test addressed nodes within a document to determine whether they match a pattern or not.

XPath is mainly used in [XSLT](/docs/Web/XML/XSLT), but can also be used as a much more powerful way of navigating through the [DOM](/docs/Web/API/Document_Object_Model) of any XML-like language document using XPathExpression, such as [HTML](/docs/Web/HTML) and [SVG](/docs/Web/SVG), instead of relying on the Document.getElementById() or Document.querySelectorAll() methods, the Node.childNodes properties, and other DOM Core features.

XPath uses a path notation (as in URLs) for navigating through the hierarchical structure of an XML document. It uses a non-XML syntax so that it can be used in URIs and XML attribute values.

## Guides

The [XPath guides](/docs/Web/XML/XPath/Guides) cover practical snippets and describe how to use XPath in JavaScript.

- [Introduction to using XPath in JavaScript](/docs/Web/XML/XPath/Guides/Introduction_to_using_XPath_in_JavaScript)
- : Describes a non-XSLT use of XPath.
- [XPath snippets](/docs/Web/XML/XPath/Guides/Snippets)
- : These are JavaScript utility functions, that can be used in your own code, based on XPath APIs.

## Reference

The [XPath reference](/docs/Web/XML/XPath/Reference) covers all XPath axes and functions documented on MDN.

- [XPath:Axes](/docs/Web/XML/XPath/Reference/Axes)
- : List and definition of the axes defined in the XPath specification. Axes are used to describe the relationships between nodes.
- [XPath:Functions](/docs/Web/XML/XPath/Reference/Functions)
- : List and description of the core XPath functions and XSLT-specific additions to XPath.

## See also

- [XSLT](/docs/Web/XML/XSLT), [XML](/docs/Web/XML), [DOM](/docs/Web/API/Document_Object_Model)
- [Transforming XML with XSLT](/docs/Web/XML/XSLT/Guides/Transforming_XML_with_XSLT)
- [Comparison of CSS Selectors and XPath](/docs/Web/XML/XPath/Guides/Comparison_with_CSS_selectors)
- [What is XSLT?](https://www.xml.com/pub/a/2000/08/holman/) introduces XSLT and XPath, including background, context, structure, concepts, and terminology - xml.com (2000)
- [XPath tester](https://extendsclass.com/xpath-tester.html) online XPath Builder/Debugger

source: MDN Web Docs mirror · page

Cite this

"XPath". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/XML/XPath

JSON record · API collection · citation policy