XPath Tester
The XPath Tester is a free online tool that helps you test XPath expressions against XML documents to find matching elements and check query results instantly.
Test an XPath expression
XPath results
What Is an XPath Tester?
An XPath Tester is a developer tool used to evaluate XPath expressions against an XML document. XPath, short for XML Path Language, provides a way to navigate XML elements and attributes, filter data, and select specific nodes.
This online XPath tester is useful for developers, testers, and anyone working with XML data who needs to check whether an XPath expression returns the expected results.
How to Test XPath Online
Enter XML input: Paste your XML document into the XML Input field.
Enter an XPath expression: Type an expression into the XPath Expression field, such as //book/title.
Click Test: Run the expression against the supplied XML.
Review the output: Examine the matching results returned by the tool.
Solved Example: Test an XPath Expression
Suppose the XML document contains two books, and the goal is to find the title of any book published after 2024.
Input:
<catalog>
<book id="1">
<title>Learning XPath Essentials</title>
<author>Jane Doe</author>
<price>29.99</price>
</book>
<book id="2">
<title>Advanced Web Scraping</title>
<author>John Smith</author>
<price>45.50</price>
</book>
</catalog>
XPath Expression: //book[@id="2"]/title
Output:
<title>Advanced Web Scraping</title>
Explanation: The expression selects the title of each book whose year is greater than 2024. Only the second book meets this condition, so its title is returned.
Common XPath Expressions
Here are some useful expressions for testing XML documents:
//book — Selects all book elements.
//book/title — Selects title elements inside book elements.
//book[@id='1'] — Selects book elements with an ID of 1.
//book[year > 2024] — Selects books published after 2024.
//book/author/text() — Selects the text inside author elements.