Home >
Online Product Documentation >
Table of Contents >
Obtaining the Text Contained in a Node
Obtaining the Text Contained in a Node
You can use the
string()
function to obtain the text in a node. The string value of an element node is the concatenation of the string values of all text node descendants of the element node in document order. Use one of the following formats:
Replace pathExpression with the path of the node or nodes that contain the text you want. This can be a rooted path or a relative path. It need not be a single node. If you do not explicitly specify the
string()
function, you must specify pathExpression in a context where the XPath processor must treat it as a string, for example:
The XPath processor obtains the text contained in each
title
element and compares it with
"Trenton Revisited"
. The XPath processor returns books with the title
Trenton Revisited.
For additional information about the
string()
function, see
Converting Objects to Strings.