XPath Functions

Contact Us or call 1-877-932-8228
XPath Functions

XPath Functions

Functions are often used within predicates to help identify a node or node set or to find out information about a node or node set. Below are reference tables showing some of the more common core XPath functions.

Node Set Functions
Function Description
last() Returns the number of the number of items in the selected node set.
position() Returns the position of the context node in the selected node set.
count() Takes a location path as an argument and returns the number of nodes in that location path.
id() Takes an id as an argument and returns the node that has that id.
String Functions
Function Description
starts-with() Takes a string and substring as arguments. Returns true if the string begins with the substring. Otherwise, returns false.
contains() Takes a string and substring as arguments. Returns true if the string contains the substring. Otherwise, returns false.
substring-before(string, substring) Returns the portion of the string to the left of the first occurrence of the substring.
substring-after(string, substring) Returns the portion of the string to the right of the first occurrence of the substring.
substring() Takes a string, start position and length as arguments. Returns the substring of length characters beginning with the character at start position.
string-length() Takes a string as an argument and returns its length.
name() Returns the name of an element.
text() Returns the text child nodes of an element.
Boolean Functions
Function Description
boolean() Takes an object as an argument. Returns true if: the object is a number greater than zero, the object is a non-empty node-set, the object is a string with at least one character.
Number Functions
Function Description
sum() Takes a node-set as an argument and returns the sum of of the string values of the node-set.
ceiling() Takes a number as an argument and returns the rounded-up value.
floor() Takes a number as an argument and returns the rounded-down value.
round() Takes a number as an argument and returns the rounded value.
Next