Skip to content

SelectSingle

Selects a single node based on the specified XPath expression.

1
myXml.SelectSingle(xpath: string):Xml

Selects a single node based on the specified XPath expression and executes a callback function if a node is found.

1
myXml.SelectSingle(xpath: string, callback: (node: Xml) => void):Xml

Parameters

string xpath
    The XPath expression to use for selecting the node.

(node: Xml) => void callback
    A callback function to execute on the selected node.

Returns

An Xml object representing the selected node. Returns null if no matching node is found. An Xml object representing the selected node. Returns null if no matching node is found.

Remarks

If multiple nodes match the XPath expression, the first node is selected.

Basic usage

1
2
3
4
var customerNode = $Xml.SelectSingle('//Customer');
if (customerNode) {
  ...
}

If multiple nodes match the XPath expression, the first node is selected.

Using callback function

1
2
3
$Xml.SelectSingle('//Customer', function(customer) {
   var customerId = customer.Evaluate('Id');
});

See Also