XML XPath Query Tool
Query XML documents using XPath expressions
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?
XPath (XML Path Language) is a W3C standard for addressing parts of an XML document. Expressions like //person, /root/item, or //*[@id='1'] select elements by path, name, or attribute. XPath is used in XSLT, XQuery, and many XML APIs. The XPath 3.1 specification defines the full syntax.
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 <strong>Sample</strong> 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 <strong>Copy</strong> 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
Common XPath examples?
/root selects the root element. //tag selects all elements named tag anywhere. //*[@attr='val'] selects elements with attribute attr equal to val. Use [] for predicates. See MDN XPath for more.
What about namespaces?
XPath with namespaces depends on the implementation. Prefixes must match the namespace declarations in your XML. If your XML uses default namespaces, you may need to use local-name() or register namespace prefixes. Check the result for your specific XML.
Is my data private?
Yes. Parsing and XPath evaluation run entirely in your browser. No XML or query is sent to any server. You can verify this in your browser's Network tab.
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.