Skip to content

SetDefaultValue

Sets the value of the current node if it is empty.

1
myXml.SetDefaultValue(value: any):void

Sets the values of all nodes at the specified XPath if they are empty.

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

Parameters

any value
    The value to update.

string xpath
    The XPath of the node to set. If not specified, the current node is used.

Remarks

Example

1
$Xml.SelectSingle('Customer/Name').SetDefaultValue('Unknown Name');

Updates the current node value

1
2
3
$Xml.SelectAll('//Customer', function() {
 this.SetDefaultValue('Name','Unknown Name');
});

Update with an XPath

1
$Xml.SetDefaultValue('//Customer/Id','1');

Updates the current node value

1
2
3
var xml = $Xml.SelectSingle('//Customer/Id', function() {
  this.SetDefaultValue('1');
});

Updates the form submission date if it is empty

1
$Xml.SetDefaultValue('Date', DateTimeOffset.now);

See Also