Append new child item to specific node
<p>How do I updates an XML file with PowerShell previously selecting the right node?</p>

<p>I've tried so far:</p>

<pre class="lang-bsh prettyprint-override"><code>$PATH = ".\file.xml"
$XML = [xml](Get-Content -path $PATH)

$NSMGR = New-Object System.Xml.XmlNamespaceManager($XML.NameTable)
$NSMGR.AddNamespace("ns", $XML.DocumentElement.NamespaceURI)

$XML.selectSingleNode("//ns:component[@name='Microsoft-Windows-Shell-Setup']", $NSMGR)

$NEWCHILD = $XML.CreateElement("TESTELEMENT")
$NEWCHILD.set_innerXML("TESTTEXT")

$XML.save(".\file.xml")
</code></pre>

<p>I want to add a child item to the node <code>&lt;component&gt;</code>. There is more than one <code>&lt;component&gt;</code> node, so I need to preselect the right one by the name.</p>