Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Copies current and all child xml nodes from sourceXPath to target xpath or target navigator.

Xml myXml.Copy(sourceXPath: string, target: ( string | Xml ))

Arguments

string sourceXPath
to copy. If you want to use current node specify as ".".
( string | Xml ) target
Target Xml or Xpath to be copy.

Remarks

This method tries to find type of copying node from XML schema. If the related scheme is found, the operation is copied based on XML scheme definitions. Otherwise it copies only name matching nodes.

Copying by XML scheme definitions automatically resolves collection items and creates new nodes.

Assume $Xml content has following data;

Example

Sample Data

Code Block
languagejs
<root>
  <Person>
    <Name>john</Name>
    <Surname>x</Surname>
  </Person>
  <Person2>
    <Name></Name>
    <Surname></Surname>
  </Person2>
</root>

Example

Copy Simple Node

Code Block
languagejs
$Xml.Copy( 'Person/Name', 'Person/Surname' );

Example

Copy complex node

Code Block
languagejs
$Xml.Copy( 'Person', 'Person2' );