XPath Tester

Your XPath expression

Your XML string

This online tool allows you to test your XPath expressions / queries against an XML string or file.You can easily debug your XPath expressions!

This utility also includes an XPath generator that helps you easily create XPath expressions. Double click (In "Your XML string" editor) the element, attribute, or text you want to generate the associated xpath expression.

You can see example XPath expression to help you to find your Xpath query.

You can see the user guide to help you to use this XPath tester.

User guide

In order to test your XPath expression, you must:

  • Fill "Your XPath expression" editor
  • Fill "Your XML string" editor
The result will be automatically generated and available in the "Results" editor.

To fill "Your XML string" editor, you can:

  • Copy and paste your XML string
  • Drag and drop your XML file
  • Click on "Browse XML file" button in order to load your XML file
  • Directly type your XML string in the editor

To generate an XPath expression:
Just double click on the element, attribute, or text you want to generate the Xpath expression.

This tool does not support the XPath functions (number(), string(), string-length() ...).

About XPath

XML Path Language (XPath) is a query language for selecting nodes from a XML data. Xpath can be used to query XML databases.

It is based on a tree representation of the XML,it allows to navigate through elements in an XML document.

XPath uses path expressions to select nodes in an XML document.

XPath expressions can be used in many programming languages (JavaScript, Java, PHP, Python, C, ...).

XPath is a W3C recommendation.

XPath Examples

Select the tools element/tools
Select all tool elements which are direct children of the tools element/tools/tool
Select all tool elements without taking into account the tree//tool
Select the second tool element//tool[position()=2]
Select the value attribute of all tool elements without taking into account the tree//tool/@value
Select the tool element which has the id attribute value of 1//tool[@id=1]

This tool uses document.evaluate function to test your XPath query.

Why use an Online XPath Tester ?

This XPath online tool does not require installation or registration, it saves time to do tests.Moreover, it is interactive, as soon as you enter your XPath string it you can see directly what matches,which further reduces the time required for testing.

XPath generator is a beta version, if you find a bug, do not hesitate to let us know.

You can report a bug or give feedback by adding a comment (below) or by clicking "Contact me" link (at the top right hand corner of the page).


Anonymous-2019-03-26 09:28
does not seem to work in firefox: An error has occured: Node cannot be used in a document other than the one in which it was created

Cyril (admin)-2019-07-21 19:16
Thank you for the feedback, it is corrected. Sorry for the delay, I did not see your comment!

krish-2020-08-02 13:57
Your XPath expression should have scroll bar to navigate up and down, bcz if the xpath is displayed in 2 lines then 'Your XPath expression' seems to blank

Cyril (admin)-2020-08-03 21:50
Thank you for this issue, I will fix it soon.

Cyril (Admin)-2020-08-07 10:21
It is fixed :)

Deceptio-2020-12-04 10:02
Great Tool this xpath tester. The design is minimalistic and clean! Thank you
One idea would be that the results are also displayed in color in the "Your XML string" window.
So when you write //tool the 3 entries are marked in color

Jim-2020-12-14 19:33
I cannot seem to find an xpath tester that supports namespaces in the query. Eg. /t:Types/t:Override[@ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"]

Christopher Pena-2020-12-15 10:58
Excellent online xml/xpath tool!

baltasar-2021-12-02 18:49
is it possible to add the count of results? (or post this page's source on github and I can try to do it myself).

other than that. thanks this is helpful

Thomas Guretzki-2022-03-22 13:30
When entering an xpath which returns a plain string (like "abc", string(/tools/tool[1]/@section) or concat("a","bc"), I get the error "The result is not a node set, and therefore cannot be converted to the desired type."
Is it possible to display such results, too?

G-2022-11-07 21:18
Namespaces are apparently not supported, and XML parsing errors are not displayed. This can result in "Results" being empty with no obvious reason.