Skip to content

XmlNode.Save

Overview

string[] XmlNode.Save ( [ xquery ], [ targetPath ] )
Saves current node outerxml to $XmlRepository

Arguments

String xquery

Specifies the xquery to save filtered results. If set to null current node outer xml content will be saved.

String targetPath

Specifies the repository target path. If set to null uses the root path of repository. Path can be seperated by '/' character.

Remarks

Registered namespace prefixes are implicitly declared while performing xquery.

Examples

Saving current node content to repository under 'Customers' path.

$Xml.Save(' ', 'Person/' + $Xml.Evaluate('Id'));
Saving child node 'Addresses' to repository.

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

Saving basic transformed result to repository.

$Xml.Save('for $c in //Person                                ' +
          'where $c/Surname                                  ' +
          'return                                            ' + 
          '  <Person>                                        ' +
          '    <Name>{ $c/Name }</Name>                      ' +
          '  </Person>                                       ');
Saving advanced transformed result to repository.

$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

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