XPath Functions

Type conversion

string()
number()
boolean()

Boolean functions

not(expr)         # button[not(starts-with(text(),"Submit"))]

String functions

contains()        # font[contains(@class,"head")]
starts-with()     # font[starts-with(@class,"head")]
ends-with()       # font[ends-with(@class,"head")]
concat(x,y)
substring(str, start, len)
substring-before("01/02", "/")  #=> 01
substring-after("01/02", "/")   #=> 02
translate()
normalize-space()
string-length()

Node functions

name()            # //[starts-with(name(), 'h')]
text()            # //button[text()="Submit"]
                  # //button/text()
lang(str)
namespace-uri()
count()           # //table[count(tr)=1]
position()        # //ol/li[position()=2]
Comments