SetDefaultValue
Sets the value of the current node if it is empty.
| myXml.SetDefaultValue(value: any):void
|
Sets the values of all nodes at the specified XPath if they are empty.
| 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.
Example
| $Xml.SelectSingle('Customer/Name').SetDefaultValue('Unknown Name');
|
Updates the current node value
| $Xml.SelectAll('//Customer', function() {
this.SetDefaultValue('Name','Unknown Name');
});
|
Update with an XPath
| $Xml.SetDefaultValue('//Customer/Id','1');
|
Updates the current node value
| var xml = $Xml.SelectSingle('//Customer/Id', function() {
this.SetDefaultValue('1');
});
|
| $Xml.SetDefaultValue('Date', DateTimeOffset.now);
|
See Also