I have an XML doccument that looks like this:
<Task>
<Settings>
</Settings>
<Sub>foo</Sub>
<Body>bar</Body>
</Task>
From PowerShell I can happily get the contents of 'Sub' and 'Body' using:
$Body = $XMLFile.Task.Body
But I am trying to REMOVE the 'Sub' and 'Body' Tags completely so the XML would be:
<Task>
<Settings>
</Settings>
</Task>
I have already Tried many things, Including:
- Using the
.RemoveChild()method (Threw an exeption relating to Object reference) - Removing with an XPath Statement and adding a Pipe to remove in one line
Even opening the file as a text file and trying:
Get-Content $_.FullName -notmatch "<Sub>" | out-file $_.FullName
^^ This does nothing at all
Also for this application of script I would be unable to use any third party modules