Skip to content

Copy

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

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

Parameters

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;

Sample Data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<root>
  <Person>
    <Name>john</Name>
    <Surname>x</Surname>
  </Person>
  <Person2>
    <Name></Name>
    <Surname></Surname>
  </Person2>
</root>

Copy Simple Node

1
$Xml.Copy( 'Person/Name', 'Person/Surname' );

Copy complex node

1
$Xml.Copy( 'Person', 'Person2' );

See Also