XPath Tester

Paste XML, type an XPath expression and see what it selects: every matching element, attribute or piece of text, each with its line so you can jump to it. Functions such as count() and sum() show their result directly.

  • Free daily uses
  • Runs in your browser
  • No sign-up needed

Last updated

Plan: FreeView packages →

Processed in your browser. Your XML is not uploaded.

100 of 100 operations left today

Type an XPath 1.0 expression, then press Enter or Run XPath.

Try:
XML input

Result

The result appears here

Guide

How to test an XPath expression

Three steps to see exactly what an XPath expression selects in your XML.

  1. Add your XML

    Paste XML into the XML input box, drop an .xml file onto it, or click Open file. Click Sample to try it with a small shop of two books; it also fills in an example expression.

    The XML input box with a sample shop of two books and the message that it is well-formed XML.The XML input box with a sample shop of two books and the message that it is well-formed XML.
  2. Type an XPath expression

    Type it in XPath expression, or click one of the examples under it, such as count(//book). The line under the box tells you as you type whether the expression is valid.

    The XPath expression box with //book[price > 25]/title/text(), the message that it is valid, and example expressions to click.The XPath expression box with //book[price > 25]/title/text(), the message that it is valid, and example expressions to click.
  3. Press Run XPath

    Press Run XPath or Enter. Every match is listed on the right with its type and line; click the line to jump to it in the XML. Copy and Download give you all the results as text.

    The sample XML on the left and one match on the right: the text of the first book's title, with its line.The sample XML on the left and one match on the right: the text of the first book's title, with its line.

Good to know

  • Nothing is uploadedThe expression runs in your browser's own XPath engine. Your XML never leaves your device.
  • Daily usesEach successful run counts as one XML operation. XML with mistakes is never counted.
  • Default namespace?If the XML has xmlns="…", match elements with *[local-name()='name'].

Frequently asked questions

Which version of XPath is supported?

XPath 1.0, the version built into every web browser and used by most XML libraries, XSLT 1.0, Selenium and many scrapers. All its axes, operators and functions work, such as contains(), starts-with(), normalize-space(), count() and sum(). Functions added in XPath 2.0 and later, such as matches(), lower-case() or string-join(), are not available.

Why does my expression find nothing when the XML has a namespace?

In XPath 1.0, a name without a prefix only matches elements that have no namespace. If the document declares a default namespace with xmlns="…", its elements belong to that namespace, so //book finds nothing. Write //*[local-name()='book'] instead; the tester reminds you when this happens.

Can I use namespace prefixes such as dc:title?

Yes. Every prefix declared in the XML with xmlns:prefix="…" can be used in the expression, so //dc:title works when the document declares xmlns:dc. A prefix that the XML doesn't declare is reported with a clear message.

What do the results show?

For a node selection, each match is listed in document order with its type (element, attribute, text…), its name and its content, plus the line where it is. Click the line to jump there in the editor. Expressions that return a number, a text value or true/false, such as count(//book), show that value instead.

Is my XML uploaded or stored?

No. The expression runs in your browser with its built-in XPath engine, so your XML never leaves your device. Our server only records that one operation was done, along with your network address, so the daily limit shown above the tool can be applied.

What counts towards the daily limit?

Each run of a valid expression on well-formed XML counts once, even when nothing matches. Checking the expression's syntax as you type, and mistakes in the XML or in the expression, are free.

More XML tools