Skip to content
All tools›Validators›XPath Tester

XPath Tester

Test your XPath expressions against an XML document. Supports XPath functions (string(), number(), name(), string-length()...).

Loading tool...

XPath examples

XPath (XML Path Language) selects nodes and computes values from an XML document. An expression is evaluated against the document and returns a sequence of items: nodes or atomic values.

Common expressions

Expression Result
/catalog/cd All cd elements that are children of the root catalog element.
//cd All cd elements anywhere in the document.
//cd[price > 10]/title Titles of the CDs whose price is greater than 10.
//cd[@id='2']/artist The artist of the CD whose id is 2.
count(//cd) The number of CDs.
sum(//price), avg(//price), max(//year) Aggregates over the numeric values.
//cd[contains(title, 'heart')] CDs whose title contains "heart".
//cd[starts-with(artist, 'Bo')]/title Titles of the CDs whose artist starts with "Bo".

Axes

following-sibling, preceding-sibling, parent, ancestor, descendant, self — walk the document tree in any direction.

Namespaces

Every namespace prefix declared in the document is available in your expression with the same prefix. If the document declares a default namespace, unprefixed element names in the expression are resolved in that namespace as well.

---