October 2017
Intermediate to advanced
440 pages
11h 47m
English
Nodes (elements, attributes, and so on) may be copied and moved between different XML documents. To bring a node from an external document into another, it must first be imported.
The following example creates two simple XML documents. The first (the variable xml) is the intended destination. The newNodes variable contains a set of elements that should be copied:
[Xml]$xml = @" <?xml version="1.0"?> <list type='numbers'> <name>1</name> </list> "@ [Xml]$newNodes = @" <root> <name>2</name> <name>3</name> <name>4</name> </root> "@
To copy the name nodes requires each node to be selected (in turn), imported into the original document, and added to the desired node:
foreach ($node in $newNodes.SelectNodes('/root/name')) ...Read now
Unlock full access