Skip to content

SetValue

Sets the value of the current node.

1
myXml.SetValue(value: any):void

Sets the value of all nodes at the specified XPath.

1
myXml.SetValue(xpath: string, value: any):void

Parameters

any value
    The value to set.

string xpath
    The XPath of the node to update.

Remarks

Strings, numbers, booleans, DateTimeOffset values and identities are converted to their XML representation. null clears the node value. Assigning a file sets the node value to the file ID and its Caption attribute to the file name.

Every node selected by the XPath is updated. Nodes are not created: when the XPath selects nothing, the call has no effect. Use Xml.AppendChild to create missing nodes.

Examples

Update the value of a selected node

1
$Xml.SelectSingle('Approved').SetValue(true);

Update values with XPath

1
2
3
$Xml.SetValue('Approved', true);
$Xml.SetValue('DueDate', $Calendar.AddDays($Calendar.Today, 7));
$Xml.SetValue('Customer/Email', null);                   // clears the value

Update every matching node

1
2
// sets the quantity of every line to 1
$Xml.SetValue('Lines/Line/Quantity', 1);

See Also