Skip to content

EvaluateBoolean

Returns the boolean value of the current node.

1
myXml.EvaluateBoolean():boolean

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

1
myXml.EvaluateBoolean(xpath: string):boolean

Parameters

string xpath
    The XPath expression to evaluate. If not specified, the current node is used.

Returns

  • (): The boolean value of the current node.
  • (xpath): The boolean value of the selected node.

Remarks

This method checks whether the evaluated value is, case-insensitively, equal to "false", "0", or an empty value. All other values are evaluated as true.

Examples

Read the boolean value of a selected node

1
var approved = $Xml.SelectSingle('Approved').EvaluateBoolean();   // false

Branch on a boolean value

1
2
3
if (!$Xml.EvaluateBoolean('Approved')) {
    throw new Error('Order ' + $Xml.Evaluate('Id') + ' is not approved.');
}

Evaluate an XPath condition

1
var hasBulkLine = $Xml.EvaluateBoolean('count(Lines/Line[Quantity > 1]) > 0');   // true

See Also