Developer Tools
XPath Tester and Evaluator
Test XPath 1.0 expressions against XML or HTML in your browser. See matching elements, attributes and text, or the number, string or boolean a function returns.
How to use XPath Tester and Evaluator
Paste an XML or HTML document, type an XPath expression and pick the document type. Matches are listed as you type with their node type, name and value; switch Show matches as to Full markup to see the elements' code.
- Paste the documentPaste XML such as a feed or sitemap, or the HTML of a page you want to scrape.
- Write the expressionTry //book[price < 20]/title, //book/@category, //title/text() or count(//book) on the sample.
- Check the matchesRead the match count and table, choose Text content or Full markup, and fix any error message shown.
XML and HTML modes
XML (strict) parses the document as XML, so an unclosed tag or a bare & stops with the parser's own error message and a hint to try HTML mode. HTML (lenient, auto-corrected) parses the way a browser does: missing html, head and body elements are added, unclosed tags are closed and tag names match in lower case, which makes it a good place to try out scraping rules. With the sample bookstore, //book[price < 20]/title returns one match, The Remains of the Day, while //book/@category returns two attributes, programming and fiction.
Namespaces and result types
XPath 1.0 cannot match elements in a default namespace by bare name, so in a sitemap that declares xmlns, //url finds nothing. When that happens the tester suggests a local-name() form such as //*[local-name()='url'], and any prefixes declared in the document can be used directly. Expressions that return nodes list elements, attributes, text, comments and other node types, up to 500 matches. Expressions such as count(//book), string(//title) or boolean(//price) return a single number, string or boolean, shown as the result with its type.
Accuracy and data handling
Validate the result with your project's own tests and runtime rules before using it in production. The calculation runs in your current browser; the tool code does not send the input to a processing API.
FAQ
Why does //title match nothing?
Most often the XML has a default namespace (xmlns=…), which bare names in XPath 1.0 cannot match. Use //*[local-name()='title'], or check that the case and spelling of the tag match.
How do I get only the text of a node?
Add /text() to the path, as in //title/text(), or wrap it in string(), as in string(//title), which returns the text of the first match only.
Does it support XPath 2.0 or 3.0?
No. Browsers implement XPath 1.0, so functions such as matches() or lower-case() are unavailable, while contains(), starts-with(), substring() and count() all work.
More Developer Tools
Related toolsPreview the next runs of a cron expression with a plain-English summary
Convert Linux file permissions between 755 and rwxr-xr-x, with chmod commands
Validate UUIDs, detect the version and decode v1, v6 and v7 timestamps
Read the timestamp in a ULID, validate it and convert it to or from a UUID
See every JWT claim explained, with readable times and expiry status
Convert text or bytes to Base32 and decode Base32, including TOTP secrets