What is XPath - XPath syntax
what is xpath - the xpath language is used for finding information in an xml document.it is a query language for selecting nodes from an xml document.
xpath provide a common syntax and behavior model between xpointer and xslt
xpath language can be used to compute values(e.g. string, numbers, or boolean values) from the content of an xml document.xpath also support namespaces and data types.xpath expressions used to navigate in xml documents.xpath was defined by the word wide web consortium(w3c).
XPath syntax and semantics
the most important kind of expression in xpath is a location path.a location path consists of a sequence of location steps.each step has three parts.
- an axis
- a node test
- zero or more predicates.
the xpath syntax comes in two flavours:
- abbreviated syntax.
given source xml containing at least
<a> <b> <c> </c> </b> </a>
the simplest xpath takes a form such as
- expanded syntax
in the full, unabbreviated syntax, the examples above would be written
xpath standart functions
xpath 1.0 defines four data types:node-sets, string, numbers, and booleans.
xpath language provides a complete set of function library, which includes:
- functions to manipulate strings:concat(),substring(),contains() much more.
- functions to manipulate numbers: sum() , ruound(), floor(), ceiling()
- functions to get properties of nodes.
- functions to get information about the processing context.
- type conversion functions: string(), number(),boolean().
xpath and xquery, xslt
In fact, in order to use xslt(to transform the contents of your xml document), you need to use xpath.xpath is a key role in xslt document.
you can read more about our xslt tutorial.
xquery 1.0 and xpath 2.0 share the same data model and support the same functions and operators.
xpointer and xquery are built on xpath expressions.
you can read more about our xquery tutorial and xpointer tutorial