Removing XML Nodes

I am wanting to remove fields from an xml export, but I can’t seem to find the correction solutions on doing this. I have the below so far but with no luck. This just exports the exact same file and doesn’t delete the 2 xml fields I would like deleted. I will end up having a lot more to delete than the 2.

$Input = "C:\Interfaces\Input.xml"
$Output = "C:\Interfaces\Export.xml"

$Doc = [xml](Get-Content $Input)

# Tags To Delete
$DeleteNames = "Prmtime","LocationTime"
($Doc.Task.ChildNodes |Where-Object { $DeleteNames -contains $_.Name }) | ForEach-Object {




First you should read and then provide sample xml data.

it will be easy if you can share the XML or a sample one here. Use to share the xml here. The XML structure is very much relevant to understand to use the parent and method to use here.