NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm, #3191 most downloaded on npm
DOM 3 XPath implemention and helper for node.js and the web
Latest stable
0.1.0
Last release 5 days ago
22 Nov 2026
Release timing varies
gaps range from 1 weeks to 2.8 years
Most releases are documented
notes for 23 of 26 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
26 releases · first in 2012
Drag across the ruler to compare, or tap a release to open it.
…boolean, or null when nothing matched (see the breaking change above: this used to be undefined).
"No node" is now always null (#140). These used to return undefined
when there was no node to return:
select1(), select(..., true), selectWithResolver(..., true), the
functions useNamespaces() returns (with single), and
parse(...).select1(), when nothing matched. Scalar results are
unchanged.iterateNext() on an iterator result from evaluate(), after the last
node, and snapshotItem() on a snapshot result, when there is no node at
that index, as the DOM specifies.This matches singleNodeValue and XNodeSet's first(), which already
returned null. To migrate, change checks for === undefined to
=== null; checks with == null, and truthiness checks, work either way.
The TypeScript types say null too: SelectSingleReturnType,
XPathEvaluator.select1(), and XPathResult's iterateNext() and
snapshotItem().
The TypeScript interface XPathResult in xpath.d.ts is renamed to
XPathEvaluationResult. It describes the values custom functions receive
as arguments and that XPathEvaluator.evaluate() returns
(booleanValue(), numberValue(), stringValue(), and toArray() /
first() / size on node sets). It was added in 0.0.36.
This is a type-only change: nothing changes at runtime. The name
XPathResult now belongs to the DOM 3 XPathResult class that
xpath.evaluate() returns and the library exports as
xpath.XPathResult (xpath.XPathResult.ANY_TYPE, etc.), which is
unchanged.
To migrate, replace type references to XPathResult from this package
with XPathEvaluationResult. The documentation page moved from
docs/XPathResult.md to docs/XPathEvaluationResult.md.
The return types of select() and select1() now match what they
return at runtime (#123):
select() (SelectReturnType) returns an array of nodes or a string,
number or boolean. It never returns a single node or null.select1() and select(..., true) (SelectSingleReturnType) return a
node, a string, number or boolean, or null when nothing matched (see
the breaking change above: this used to be undefined).Code that assigns select1()'s result to a type without null no longer
compiles. The new ScalarValue type is the string, number or boolean
case. SelectedValue is deprecated but still exported, with its previous
meaning, and select1()'s result can be assigned to it.
The type guards (isNodeLike(), isArrayOfNodes(), isElement() and
the other is…() functions) now accept any value, including null,
undefined and nodes from DOM properties such as parentNode, as they
always have at runtime. They also now return false for null,
undefined, 0, '' and NaN, where isNodeLike() and the node-type
guards used to return the value itself.
XPathContext.prototype.clone(), which copies a fixed set of fields,
instead of copying every property (#146). On the benchmark in #146
(100,000 selections), evaluation took about a third to a half as long.XPathContext are no longer
copied to the contexts that location paths and predicates are evaluated
with. Only the library's own context fields are (#146).push() and one reverse() instead of unshift() (#120).
Parsing a 3,000-term union and a 3,000-term sum took about a quarter less
time.XPathContext.prototype.extend(). The library no longer uses it. It still
works as before, logs a deprecation warning the first time it's called,
and will be removed in a future version (#146). To copy an XPathContext,
use clone() and set any extra properties on the copy. Unlike extend(),
clone() copies only the library's own context fields, not custom
properties.xpath.evaluate() is typed again (its typing was dropped in
0.0.33, #116), and xpath.XPathResult is declared as a class with its
result-type constants, such as xpath.XPathResult.STRING_TYPE (#121).following:: no longer includes the context node's descendants (and no
longer misses nodes that come after them), and preceding:: no longer
includes its ancestors, as XPath 1.0 §2.2 specifies. Both also work for
attribute and namespace context nodes (#150; fix from #153 by bardrop).number() or in arithmetic) now
follows XPath number syntax, as converting a string already did. So a
node whose value is hexadecimal (0x10), uses an exponent (1e3), is
empty, or is Infinity gives NaN, where it used to give 16, 1000, 0 or
Infinity (#152 by icguner).number("42.") and a node containing 42. give 42, not
NaN (#152).NaN, where it used to be ignored (#161).substring() follows XPath 1.0 §4.2 for its bounds: a NaN start, or a
negative or NaN length, now gives an empty string (#152 by icguner).lang() finds xml:lang on the context node or its nearest ancestor,
compares case-insensitively, and works when the context node is a text,
comment, attribute or other non-element node, where it used to throw
(#152 by icguner).id() uses each node's string-value when given a node-set, and no longer
looks up an empty ID when the argument has leading or trailing whitespace
(#152 by icguner).xpath.js no longer uses Number.isInteger(), which isn't available in
ES5 engines. It had been used since 0.0.33 to check node types, which runs
whenever an expression is evaluated against a node.42., is now
accepted, as XPath 1.0 §3.7 allows. 42., 42. + 1 and //a[1.] used to
throw "XPath parse error".package-lock.json; the repository uses yarn
(yarn.lock) for its dev dependencies (#154).xpath.d.ts (test-types.ts),
run by yarn test after the mocha tests. TypeScript is now a dev
dependency.Your coding agent can read these notes before it upgrades. Set up the MCP server →
TypeScript: added typings for xpath.parse() and the parsed-expression API (#139), including the XPathResult interface renamed in 0.1.0.
xpath.parse() and the parsed-expression
API (#139), including the XPathResult interface renamed in 0.1.0.Parsed expressions can be given the context position and size to evaluate with (#148).
isArrayOfNodes() accepts the value select() returns
(#127).xpath.d.ts in files (#124).Node positions on reverse axes are correct, and nodes are sorted before predicates are applied (#135, via #136).
Added node type test functions, with typings: isNodeLike(), isArrayOfNodes(), isElement(), isAttribute() and the other is…() helpers. Fixed issues in
isNodeLike(),
isArrayOfNodes(), isElement(), isAttribute() and the other is…()
helpers. Fixed issues in the type definitions (#116).xpath.js (validate script) (#118).@xmldom/xmldom instead of xmldom (#106,
#117); documentation install command updated (#114).NodeTest objects expose .type again (restoring earlier behavior).
NodeTest objects expose .type again (restoring earlier behavior).Fixed a "maximum call stack size exceeded" error (#99).
More of the library's internal types are exported.
Republished with no code changes from 0.0.28.
Fixed performance problems introduced after 0.0.24.
.npmignore (#80) and a LICENSE file (#94).Added the isHtml option for parsed expressions (#27). It also turns on allowAnyNamespaceForNoPrefix.
isHtml option for parsed expressions (#27). It also turns on
allowAnyNamespaceForNoPrefix.Added the allowAnyNamespaceForNoPrefix option for parsed expressions (#27).
allowAnyNamespaceForNoPrefix option for parsed expressions
(#27).Path evaluation refactored, fixing incorrect handling of the context position (#45).
numberValue() on booleans (#74).Added TypeScript type definitions (#68).
XPathEvaluator, XPathResult
(now XPathEvaluationResult) and the function and namespace resolvers;
xpath.parse() added to the API documentation.package.json is given as CC-BY-SA-2.0 (was
"Creative Commons").A meaningful error for an invalid function name (#44).
Selecting multiple attributes returns all of them (#37, #42).
Attr.value, falling back to
Attr.nodeValue (#35).Republished with no code changes from 0.0.20.
0.0.10 to 0.0.19 were never published.
0.0.10 to 0.0.19 were never published.
xpath.parse()),
with support for custom functions and variables.Node.compareDocumentPosition() when available).preceding:: axis in document fragments, and names of DOM
Level 1 elements.XPathException behaves like an Error; string() with no arguments and
string() on document fragments fixed.name() / local-name() for
processing instructions.Utilities is no longer created as a global variable.package.json changed from MIT to "Creative Commons".- Fixed substring-after() (#15).
substring-after() (#15).Fixed XPathNamespace instantiation (#10).
XPathNamespace instantiation (#10).Works in a browser as well as in Node (#3).
Namespace support (#2) and README fixes (#1).
Nothing published for this version
Nothing published for this version
Nothing published for this version
The first releases. The commit history doesn't say what changed between them: its version numbers don't line up with what was published, and 0.0.5 has
The first releases. The commit history doesn't say what changed between them: its version numbers don't line up with what was published, and 0.0.5 has no matching commit.
One column per quarter.