title: Extract a node (with all his child nodes) from an xml and print it in another xml file with Powershell
body: <p>Dears, is the first time I approach powershell scripting world...Sorry if my questions could seem basilar.</p>
  <p>Following what I need.</p>
  <p>Starting from file1.xml I need to extract a specific node (with all his underlying nodes) and write it to file2.xml</p>
  <p>The structure of the file1.xml is</p>
  <pre><code>&lt;Alias:root&gt;
    &lt;Node:Node1&gt;.......&lt;/Node:Node1&gt;
    &lt;Node:Node2&gt;.......&lt;/Node:Node2&gt;
    &lt;Node:Node3&gt;.......&lt;/Node:Node3&gt;
    &lt;Node:Node4&gt;.......&lt;/Node:Node4&gt;
    &lt;Node:Node5&gt;.......&lt;/Node:Node5&gt;
    &lt;Node:Node5&gt;.......&lt;/Node:Node5&gt;
    &lt;Node:Node5&gt;.......&lt;/Node:Node5&gt;
  &lt;/Alias:root&gt;
  </code></pre>
  <p>I don't know if can be a problem but my files will have &quot;:&quot; character in the nodes name. And some node have multiple occurrences like Node5 in the sample.
  I have to extract the first occurrence of Node:Node5 in file2.xml</p>
  <p>Hypothetical file2.xml should be:</p>
  <pre><code>&lt;Node:Node5&gt;
    .....
  &lt;/Node:Node5&gt;
  </code></pre>
  <p>I started my script opening my loading the file</p>
  <pre><code># read xml
  $xml = [xml](Get-Content file1.xml)
  # Select The node to maintain
  $Extract = $xml.SelectNodes('//*[local-name() = &quot;Node:Node5&quot;][1]')
  </code></pre>
  <p>Now I'm trying several way to redirect $Extract to file2.xml without any results.</p>
  <p>Looking similar topics I tried using this syntax but it doesn't work</p>
  <pre><code>$xml2= New-Object System.Xml.XmlDocument
  $newNode = $xml2.ImportNode($Extract, $true)
  $xml2.AppendChild($newNode)
  $xml.Save(&quot;path where saving&quot;)
  </code></pre>
  <p>I'm getting the error:</p>
  <p>Cannot convert argument &quot;0&quot;, with value: &quot;System.Xml.XPathNodeList&quot;, for &quot;AppendChild&quot; to type &quot;System.Xml.XmlNode&quot;: &quot;Cannot convert the &quot;System.Xml.XPathNodeList&quot;
  value of type &quot;System.Xml.XPathNodeList&quot; to type &quot;System.Xml.XmlNode&quot;.&quot;
  At line:8 char:2</p>
  <p>Waiting some helps
  Thanks</p>