Skip to content

SetDefaultValue

Sets the value of current node if has empty value.

1
myXml.SetDefaultValue(value: any):void

Sets the all node values on specified xpath if has empty value.

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

Parameters

any value
    Value to update

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

Remarks

Example

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

Update current node value

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

Updates with an xpath

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

Updates current node value

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

Update form submit date if its empty

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

See Also