Skip to content

Save

Saves the current node's content to the $XmlRepository.

1
myXml.Save(xquery?: string, targetXPath?: string, collection?: string):Array<string>

Parameters

string xquery optional
    Specifies the XQuery expression to save filtered results. If set to null, the current node's outer XML content will be saved.

string targetXPath optional
    Specifies the repository target path. If set to null, the root path of the repository is used. The path can be separated by '/' characters.

string collection optional
    The name of the repository collection. When omitted, the default repository of the domain is used.

Returns

An array of strings, potentially representing the paths where the data was saved.

Remarks

Available only in server scripts.

The XQuery runs against the current node's XML, and each result is saved to the repository. Registered namespace prefixes are implicitly declared while performing the XQuery.

Examples

Save the current node

1
2
// saves the Order element under the 'Order' path
$Xml.Save();

Save a child node to a specific path

1
$Xml.Save('Customer', 'Customer');

Save a transformed result

1
2
3
4
5
6
7
$Xml.Save(
    'copy $input := . ' +
    'modify (' +
    '  delete node $input/Lines,' +
    '  insert node <SavedAt>{ current-dateTime() }</SavedAt> into $input' +
    ') ' +
    'return $input', 'OrderSummary');

Save only the rows that match a condition

1
2
3
4
$Xml.Save(
    'for $line in Lines/Line ' +
    'where $line/Quantity > 1 ' +
    'return $line', 'BulkLine');

See Also