I have the following XML tree:
You have to iterate over each node and create the address
node for each of them:
$fileName = "C:\code\employees.xml";
$xmlDoc = [System.Xml.XmlDocument](Get-Content $fileName);
$xmlDoc.company.employees.employee | Foreach-Object {
$_.AppendChild($xmlDoc.CreateElement("address"))
}
$xmlDoc.Save($fileName);
Output:
If you need more subchildren, just assign the output of the AppendChild
to a variable and use it to Append them.