Free XPath Query Tester Online
Test XPath expressions against XML documents right in your browser
XML Input
XPath Results
XPath Examples
XPath selects nodes from XML. Telecom-themed example:
Subscribers XML
Example XPath expressions:
Paste the XML and expression above, then click Execute. Use Sample to load the same data.
What Is XPath?
Digging through large XML files to find the right nodes is tedious without the proper query language. XPath (XML Path Language) solves that — it is a W3C standard for addressing parts of an XML document. Expressions like //person, /root/item[@id], or //*[@id='1'] select elements by path, name, or attribute. XPath powers XSLT, XQuery, and many browser XML APIs. This tool evaluates your expressions entirely in the browser using the built-in document.evaluate API — no data leaves your machine.
This tool parses your XML in the browser and runs XPath queries against it. Matching nodes are shown in the results panel. All processing is local; nothing is sent to a server.
How to Use This Tool
Paste or Upload XML
Paste your XML into the left editor or upload a file. Use Sample to load example data. Ensure the XML is well-formed; invalid XML may cause parsing errors. Use XML Validator if unsure.
Enter XPath and Execute
Type an XPath expression in the query box (e.g. //person, /root/item, //*[@id='1']) and click Execute. Results appear in the right panel. The query runs automatically as you type.
Copy or Inspect Results
Use Copy to copy the matched nodes to your clipboard. For converting XML to JSON, use XML to JSON. For JSONPath queries on JSON, use jq.
When XPath Helps
XPath is useful when you need to extract specific elements from XML—for example, all subscriber nodes, elements with a given attribute, or nodes at a certain depth. It's common in data integration, API responses, configuration parsing, and XSLT transformations. Use this tool to test expressions before embedding them in code or to inspect XML structure.
Frequently Asked Questions
What are some common XPath expressions?
/root selects the document root. //tag finds all tag elements anywhere. //*[@attr='val'] matches elements where attribute attr equals val. Use predicates in [] to filter results. See the MDN XPath reference for the full syntax.
How does XPath handle XML namespaces?
Browser-based XPath requires namespace prefixes to match those declared in the XML. For default namespaces (no prefix), try local-name() — for example //*[local-name()='element']. Namespace handling varies across XPath implementations.
Is my XML data sent to a server?
No. Parsing and XPath evaluation happen entirely in your browser via the document.evaluate API. Check your browser's Network tab to confirm — zero outbound requests.
Can I use XPath 2.0 or 3.1 features here?
Browsers implement XPath 1.0 natively. Advanced 2.0/3.1 functions like matches() or tokenize() require a dedicated XPath engine. This tool covers all XPath 1.0 expressions, which handle the vast majority of real-world queries.
Related Tools
For XPath syntax and semantics, see the XPath 3.1 specification and MDN XPath. For XML, see the W3C XML specification and W3C XML. For schema validation, see W3C XML Schema. For XSLT (which uses XPath), see XSLT 3.0. For JSONPath (JSON equivalent), see JSONPath and jq.