Skip to content

Evaluate

Returns the string value of the current node.

1
myXml.Evaluate():string

Returns the string value of the node selected by the specified XPath expression.

1
myXml.Evaluate(xpath: string):string

Parameters

string xpath
    The XPath expression to evaluate.

Returns

The string value of the selected node.

Remarks

Returns an empty string when the XPath does not select a node. In server scripts, an error is thrown when the XPath selects more than one node; use a predicate such as [1] to pick one, or Xml.SelectAll to read every value.

The XPath can also be an expression that calculates a value, such as concat(...) or count(...); the result is returned as a string.

Examples

Read the value of a selected node

1
var name = $Xml.SelectSingle('Customer/Name').Evaluate();   // 'Jane Doe'

Read a node value

1
2
var name = $Xml.Evaluate('Customer/Name');                 // 'Jane Doe'
var missing = $Xml.Evaluate('Customer/Phone');             // ''

Evaluate an XPath expression

1
2
var summary = $Xml.Evaluate("concat(Customer/Name, ' (', count(Lines/Line), ' lines)')");
// summary: 'Jane Doe (2 lines)'

Read a value from the pool root when

$Xml points to a nested element

1
var orderId = $Xml.Evaluate('$poolRoot/Id');

See Also