Skip to content

Sum

Returns the sum of the numeric values of child elements on the current node, or at the specified XPath.

1
myXml.Sum():number

Returns the sum of the numeric values of child elements on the current node, or at the specified XPath.

1
myXml.Sum(xpath: string):number

Parameters

string xpath
    XPath expression to evaluate. If not specified, the sum of the current node's immediate children is returned.

Returns

The sum of the numeric values. The sum of the numeric values.

Remarks

Evaluate with an XPath:

1
var totalAmount = $Xml.Sum('//Customer//Order/Total');

Evaluate with an XPath:

1
var totalAmount = $Xml.Sum('//Customer//Order/Total');