Javatpoint Logo
Javatpoint Logo

XPath String Functions

A list of XPath string functions:

Index Function Description
1) starts-with(string1, string2) It returns true when first string starts with the second string.
2) contains(string1, string2) It returns true when the first string contains the second string.
3) substring(string, offset, length?) It returns a section of the string. The section starts at offset up to the length provided.
4) substring-before(string1, string2) It returns the part of string1 up before the first occurrence of string2.
5) substring-after(string1, string2) It returns the part of string1 after the first occurrence of string2.
6) string-length(string) It returns the length of string in terms of characters.
7) normalize-space(string) It trims the leading and trailing space from string.
8) translate(string1, string2, string3) It returns string1 after any matching characters in string2 have been replaced by the characters in string3.
9) concat(string1, string2, ...) It is used to concatenate all strings.
10) format-number(number1, string1, string2) It returns a formatted version of number1 after applying string1 as a format string. String2 is an optional locale string.

XPath String Function Example

Let's take an example to create a table of <employee> element with their names and length of names, by iterating over each employee. It calculates length of the employee name after concatenating firstname and lastname and then displays the employee details.




XPATH String function 1

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA