The XPath expression tester evaluates XPath 1.0 queries against XML input using the browser's native DOM parser. Paste your XML and expression to see matching nodes, count, and extracted text values.
XPath Quick Reference
//tagany tag anywhere/root/childdirect child path@attrattribute valuetag[1]first element[@id='x']attribute predicatecount(//tag)count elementstext()text contentparent::*parent element*[last()]last elementHow to Use the XPath Tester
The XPath tester evaluates XPath 1.0 expressions against XML input using the browser's native document.evaluate() API. Paste XML, enter your expression, and see results instantly.
Step 1: Provide XML Input
Paste a well-formed XML document into the left panel. The XML must be valid — properly closed tags, quoted attributes, single root element. Click "Load example" to see a sample XML structure with books and authors.
Step 2: Enter an XPath Expression
Type your XPath expression in the input field. Start with // to select elements anywhere in the document, or use /root/child for absolute paths. The quick reference grid shows common patterns.
Step 3: Read the Results
Matching nodes appear on the right. Each result shows the element tag name, attribute values, and text content. The count badge shows how many nodes matched. For scalar expressions like count(//item), the numeric result is shown directly.
Common XPath Patterns
Select all elements with a specific attribute: //item[@category='fiction']. Select by text content: //title[text()='Dune']. Select the third child: //book[3]. Get a specific attribute value: //book/@id.
Frequently Asked Questions
Is this XPath tester free?
Yes, completely free with no signup. All XML parsing runs locally in your browser using the native DOM parser.
What XPath version is supported?
XPath 1.0 is supported via the browser's native document.evaluate() API. This covers all standard XPath axes, functions, and predicates used in everyday XML processing.
What is an XPath expression?
XPath is a query language for selecting nodes in an XML document. Examples: /root/child selects all child elements, //tag selects all tags anywhere in the document, /items/item[@id='1'] selects items with a specific attribute value, and count(//item) returns the number of item elements.
Can I test XPath against HTML?
The tool parses input as XML. For HTML, use XHTML or ensure your HTML is well-formed XML. Browsers parse HTML with a more lenient parser — this tool uses the strict XML parser which requires properly closed tags and quoted attributes.
What XPath axes are available?
XPath 1.0 supports: child, parent, ancestor, descendant, following-sibling, preceding-sibling, attribute, self, and more. Example: //div/following-sibling::p selects all paragraph elements that follow a div at the same level.