PowerShell/xml beginner here.... I'm trying to append to or remove empty xml nodes using PowerShell as part of a Nuget Package. The xml file has the following format...
<Root>
<service name="first">
<item>
</item>
</service>
<service name ="second">
<item>
</item>
</service>
</Root>
First my script select one of the services and save it as a variable, say if the user wants to select service 1.....
if ($xml.Root.service.name -eq $serviceName)
{
$myService = $xml.Root.service
}
Problem is later on, I need to append elements to the node/delete the node... I have something like
$newNode = $xml.CreateElement('new'...
.........
$empty = $myService.SelectSingleNode('./item')
$empty.PrependChild($newNode)
But I can't get the this method to work.
Any suggestions would be appreciated...