XPath 3.1 ✓ by SelectorsHub
XML Input

Drop your XML file here

Accepts .xml files
Paste / Edit XML Source
Paste XML or upload a file to begin
XPath Evaluator
Auto-Generated XPath — click any node in Tree view to generate
Rel XPath
Abs XPath

Enter an XPath and press Evaluate.
Supports XPath 1.0, 2.0, 3.0 & 3.1 functions:
ends-with · matches · avg · lower-case · upper-case
tokenize · abs · exists · empty · contains-token
encode-for-uri · has-children · || · => arrow

XPath Examples

Click Try It on any example to load it into the editor above.
Sample XML — used by all examples below bookstore.xml
Click to expand
<bookstore>
  <book category="fiction" id="b1">
    <title lang="en">The Great Gatsby</title>
    <author>F. Scott Fitzgerald</author>
    <price>12.99</price>
    <year>1925</year>
    <tags>classic american novel</tags>
  </book>
  <book category="science" id="b2">
    <title lang="en">A Brief History of Time</title>
    <author>Stephen Hawking</author>
    <price>9.99</price>
    <year>1988</year>
    <tags>science physics cosmos</tags>
  </book>
  <book category="fiction" id="b3">
    <title lang="de">Der Prozess</title>
    <author>Franz Kafka</author>
    <price>7.50</price>
    <year>1925</year>
    <tags>fiction classic literary</tags>
  </book>
  <book category="tech" id="b4">
    <title lang="en">Clean Code</title>
    <author>Robert C. Martin</author>
    <price>35.00</price>
    <year>2008</year>
    <tags>programming software engineering</tags>
  </book>
</bookstore>
XPath 1.0 The original W3C spec (1999). Fully supported natively in all browsers via document.evaluate(). Covers node navigation, predicates, string, number and boolean functions.
XPath 2.0 W3C spec (2007). Adds sequences, typed values, regular expressions, and dozens of new string/aggregate functions. Evaluated via the built-in polyfill.
XPath 3.0 W3C spec (2014). Adds the || concat operator, => arrow operator, ! simple-map, math: namespace, and higher-order functions. Polyfill-powered in this tester.
XPath 3.1 W3C spec (2017). Introduces maps and arrays as first-class types, plus JSON integration functions. Native browser support is limited — these examples run through the polyfill engine.
Map and array literals (map{}, []) are not evaluable in the browser DOM engine. The examples below show the string/node functions from 3.1 that do work, plus the syntax reference for map/array for learning.