XPath is the way to point at a part of an XML document — one book in a list, every price, all the titles. It runs your expression against your XML and shows exactly which nodes it matches, so you can check the expression before you use it in code.
Test an expression
- Paste your XML into the “Input” box. A short sample is already there — swap in your own XML.
- Type your XPath expression into the “XPath expression” field — say //title to pick out every title element.
- Click “Evaluate XPath”.
- Read the matching nodes in the output box below the buttons, then click “Copy result” to copy them.
Getting the expression right
- Start with //title. On a small XML document with book titles, //title should return every title. If it returns nothing, the XML or the expression has a typo, not the tool.
- One slash and two slashes are different. /book picks a book at the very top of the document; //book finds books anywhere inside it. Use // when you're not sure how deep the element sits.
- Paste the whole document, not part of it. XPath needs a complete, well-formed XML document. A cut-off closing tag makes the whole test fail.
- An empty result is an answer too. If the expression returns nothing, it means no node matches. Check the spelling and the capital letters, because XPath is case-sensitive.
- Your XML stays on your device. The test runs in the browser, so nothing you paste is uploaded.