XPath Functions

Version 1 of the XPath Recommendation provides a Core Function Library. The various functions provided in that library are described in this section.

XPath functions can return a data type that is one of the four XPath data types—node-set, boolean, string, or number.

Context Functions

Context functions say something specifically about the current context or in relation to the current context as a starting point.

The last() Function

The last() function is typically used in a predicate within a location path. It selects the last node in the current node list.

<Result> 
<First>John Doe</First>
<Second>Jane Doe</Second>
<Third>Robert Kennedy</Third>
</Result>

If the result element node was the context node and the path expression ...

Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.