XPath is a language for addressing parts of an XML document.
It is used in XSLT and is a subset of XQuery. Libraries are available for most other programming languages as well.
XPath is an international standard with specifications published by W3C:
XPath 1.0 doesn't have the concept of a default namespace.
Also, the namespace prefixes defined in the original XML document do not affect XPath - namespace prefixes have to be explicitly registered with the XPath provider, otherwise prefixes can't be used at all in the XPath expression.
local-name() result does not include prefix (lookup name() XPATH function for it)
Using [@attribute_name] we can select nodes that have the attribute irrespective of the value.
We can use any of the functions or combination of the functions such as starts-with and lowercase, for example, with this selector to suit our needs.
We can use this in combination of other functions and axes to suit our needs.
An XPath location path is a series of location steps separated by a /
character:
step1/step2/step3
A location step contains an axis, a node test, and an optional list of predicates. The axis and the node test are separated by two colon characters ::
. The predicates are enclosed in square brackets:
axis::nodeTest[predicate1][predicate2]
The evaluation of a location path starts with a node set containing the context node given by the context of the expression, or the root node, if the location path starts with a /
. At each step, each node N in the original node set is replaced with the set of nodes that
The result of a location path expression is the final node set obtained after processing all location steps.
These axes can be used in combination with other functions to suit our needs.
Boolean function has other uses
Boolean function has other uses
String function is used to return the string value of a node.