XPath tester
Runs only in your browser. Your data is not sent to our servers.
Paste XML and write an XPath expression. Namespace prefixes from the document are filled in for you.
Examples
Matches
XPath in short
Click an example to try it on the example data.
| Syntax | Meaning | Example |
|---|---|---|
/ | A step down from the root, or from the element before. | |
// | Search at every level below. | |
prefix:Name | An element in a namespace. Elements in a default namespace need a prefix too, here ns:. | |
@attr | An attribute. | |
* | Any element. | |
. | The current element, often used inside a condition. | |
.. | The parent element. | |
[1] | The first match by position. Positions start at 1. | |
[last()] | The last match. | |
[ ] | A condition. Keeps the elements where it is true. | |
text() | The text inside an element. | |
count() | How many matches there are. | |
sum() | The sum of the values. | |
contains() | True when a text contains another text. |
About this tool
XPath selects elements, attributes and values in an XML document. This tool supports XPath 1.0, which is what most integration platforms and XSLT 1.0 use.
Namespaces, the usual stumbling block
In SOAP and many other XML formats the elements belong to a namespace. XPath only finds them with a prefix, even when the document writes them without one.
- Prefixes the document declares, such as
soap, are used as they are. - A default namespace (
xmlns="..."without a prefix) gets the prefixns. Write//ns:Order, not//Order. - You can change the prefixes under Namespaces, so they match the ones your platform or XSLT uses.
Elements are shown as formatted XML. Expressions such as count() and sum() give a single number.
Found a problem?
Tell us what went wrong. You decide whether your own work is included.
Licences
This tool is built with these third-party libraries: