Skip to content

Save

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

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

Parameters

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

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

Returns

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

Remarks

Registered namespace prefixes are implicitly declared while performing the XQuery.
Saving the current node's content to the repository under the 'Person' path.

Example

1
$Xml.Save('', 'Person/' + $Xml.Evaluate('Id'));

Saving the child node 'Addresses' to the repository:

1
$Xml.Save('Person/Addresses');

Saving a basic transformed result to the repository:

1
2
3
4
5
6
$Xml.Save('for $c in //Person                         ' +
   'where $c/Surname                                  ' +
   'return                                            ' +
   '  <Person>                                        ' +
   '    <Name>{ $c/Name }</Name>                      ' +
   '  </Person>                                       ');

Saving an advanced transformed result to the repository:

1
2
3
4
5
6
$Xml.Save('copy $input := .                                 ' +
   '  modify(                                        ' +
   '    replace value of node $input/Name with 'X',  ' +
   '    insert node <Age>1</Age> into $input         ' +
   '  )                                              ' +
   '  return $input                                  ');

Saving with conditional processing:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
this.Save('  for $risk in //Risk                                                        ' +
    '  where $risk/Action = 'C'                                                   ' +
    '  return                                                                     ' +
    '  copy $input := $risk                                                       ' +
    '    modify (                                                                 ' +
    '      delete node $input/Tasks,                                              ' +
    '      delete nodes $input/Comments[State],                                   ' +
    '      insert node <Group>{ $risk/ancestor::Group/Name }</Group> into $input  ' +
    '    )                                                                        ' +
    '    return $input                                                            ');

See Also