<?xml version="1.0" encoding="UTF-8"?>
<People xmlns="TestData">
<Person Id="TestData" Status="TestData">
<Name>
<FirstName>TestData</FirstName>
<LastName>TestData</LastName>
</Name>
<Dimensions>
<Dimension Id="TestData" Name="TestData" Dimension="TestData" />
<Dimension Id="TestData" Name="TestData" Dimension="TestData" />
<Dimension Id="TestData" Name="TestData" Dimension="TestData" />
<Dimension Id="TestData" Name="TestData" Dimension="TestData"/>
</Dimensions>
<EmploymentInformation>
<DateHired>TestData</DateHired>
<DateRehired>TestData</DateRehired>
<EmployeeStatus>TestData</EmployeeStatus>
<JobCode>TestData</JobCode>
<Supervisor Id="TestData" Name="TestData" />
<Title>TestData</Title>
</EmploymentInformation>
</Person>
</People>
My XML document is above. I would like to remove the node 'Supervisor' under 'EmploymentInformation'. I'm having some trouble putting together my XPath... This is what I have so far:
[xml]$xml = gc C:\Users\username\Downloads\Test.xml
$supervisor = $xml.SelectSingleNode('//People/Person/EmploymentInformation/Supervisor')
$employmentInformation = $xml.SelectSingleNode('//People/Person/EmploymentInformation')
[void]$employmentInformation.RemoveChild($supervisor)
$xml.Save('C:\Users\username\Downloads\Result.xml')