XPath Query Tester

Extract data from XML using XPath expressions

XPath Query

Query with XPath

How to Use XPath

  1. 1 Paste your XML document
  2. 2 Enter an XPath expression or use a preset
  3. 3 See matched nodes highlighted instantly
  4. 4 Copy extracted results to clipboard

Input: //item[@id="1"]

Output: Finds all item elements with id="1"

Input: /root/items/item/text()

Output: Extracts text content from all items

What is XPath and how do I use it?

XPath is a query language for selecting nodes from XML documents. Use / for direct children, // for any descendant, @ for attributes, and [] for conditions.

How do I select elements by attribute value?

Use the syntax //element[@attribute="value"]. For example: //book[@category="fiction"] selects all book elements where category equals "fiction".

Can I extract just the text content of elements?

Yes! Add /text() to your XPath. For example: //title/text() returns only the text inside title elements, not the tags themselves.

Why does my XPath return no results?

Common issues: wrong element names (XPath is case-sensitive), missing namespace prefixes, or incorrect path structure. Try starting with //elementName to find any matching elements.

All processing happens locally in your browser. Your XML never leaves your device.