Test XPath 1.0 against XML with all four result types, not just node-sets, and the namespaces your document declares bound for you including the default one
Initializing in your browser…
Test regex patterns with real offsets, every capture group with its own position, all eight flags including v and y, an explanation that reads the pattern rather than guessing, and a runaway pattern stopped instead of freezing the page
Format and validate XML without changing the document: CDATA, xml:space="preserve" and mixed content all survive, with errors carrying a line, a caret and a next step, plus XPath queries, a tree view and JSON conversion that names what JSON cannot carry
Minify or beautify JavaScript, TypeScript, CSS, HTML, JSON, XML and SQL with a real lexer per language, so a comment inside a string is not deleted and a line break the code depends on is kept, with the byte saving measured
You want to know whether a document has more than two books, which is a boolean question rather than a list of nodes.
Expression
count(//book) > 2
Result
boolean: true
The result type is whatever the expression produces, not whatever the page asked for. An expression like this one used to come back as the number 1, because a number was requested and the engine coerced the boolean; string and boolean expressions failed outright. All four XPath 1.0 types work now, and the page names which one came back.
Paste an XML document, type an XPath expression, and see the answer as you type. All four XPath 1.0 result types are supported, not just node-sets, and the namespaces your document declares are bound for you, including the default one, which cannot be used in an expression without a prefix.
XPath 1.0 section 1 says an expression evaluates to one of exactly four things: a node-set, a boolean, a number or a string. Your browser has a real XPath 1.0 engine, and it is what this page uses, so the answers are correct by construction. What a tester has to get right is ASKING: the browser API takes the result type you WANT as an argument and refuses the expression if it produces something else.
This page asks for whatever the expression produces and reports which of the four came back. So `count(//book)` gives a number, `string(//title)` gives a string, `count(//book) > 2` gives a boolean, and `//book` gives a node-set, and the type is named on screen beside the count.
Namespaces are the other half. The browser API takes a namespace resolver, and without one a prefixed name in an expression cannot be resolved at all. Worse, an unprefixed name in XPath 1.0 means "in no namespace", so `//title` selects nothing in an Atom feed, which is a document full of title elements. Every namespace the document declares is read out of it and bound here, and a default namespace is given a usable prefix so it can be written; you can add a binding of your own too. When an expression is valid and selects nothing, the page says whether a namespace is the reason.
Every node in a result carries an XPath that selects exactly that node, built by numbering each step among its same-named siblings, so you can copy one and use it directly. Attributes, text nodes, comments, CDATA sections and processing instructions are all shown with the kind of node they are.
A document that is not well formed gets a line, a column, the offending line with a caret under it, and a next step, from the same checker the XML formatter uses, which agrees with the browser on every document in that tool's corpus. An expression that does not compile is reported with the browser's own message plus a next step where the shape of the expression makes one obvious: unbalanced brackets, an unclosed string, or a prefix nothing binds.
Test the expressions an XSLT template will use, including the boolean and string ones a node-set-only tester cannot evaluate.
Atom, RSS with Dublin Core, SOAP, SVG and OOXML are all namespaced, and an unprefixed expression finds nothing in any of them. The bindings are ready and the page explains the failure.
Build and check selectors before putting them in a scraper, and copy the exact path of a node you found by eye.
Query a Maven POM, an Ant build or an Android manifest, and count or sum values as well as select them.
Because the tool asked the browser for a node-set whatever the expression was, and only made an exception for expressions beginning with count( or sum(. Every string and boolean expression failed. It now asks for whatever the expression produces, and this project's tests score it against xmllint on 36 expressions covering all four types: 36 of 36, where the previous version managed 16.
Because in XPath 1.0 an unprefixed name means "in no namespace", and every element in a document with a default namespace is in one. The page binds the default namespace to a prefix for you and tells you to write it. Alternatively, local-name() ignores namespaces entirely.
XPath 1.0, which is what browsers implement. XPath 2.0 and 3.1 add sequences, a richer type system and many more functions, and no browser has them.
An XPath that selects exactly that one node, with each step numbered among its same-named siblings. Paste it back in and you get that node and nothing else, which this project's tests check for every node of every result in the corpus.
No. It is parsed and queried in your browser.
Your text is processed locally in the browser. Nothing you paste or open is transmitted or logged.