Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Delete Entire XML Element (Node)

$
0
0

How can I delete an entire XML Element after loading the XML Object?

$xml = New-Object XML

$xml.Load($pathToFile)

Each file may have multiple entries of this node with different attribute data and I want to delete all of them. In the example below I want to complete remove all instances of the element <xyz:Results /> and all associated attributes. How can I accomplish this?

 

Example XML

<xyz:ItemList>

    <xyz:Item>

             <xyz:Title>Blah</xyz:Title>

             <xyz:Results atribute1="0" attribute2="1" />

    </xyz:Item>

    <xyz:Item>

             <xyz:Title>Blah, Blah</xyz:Title>

             <xyz:Results atribute1="43" />

    </xyz:Item>

</xyz:ItemList>


Viewing all articles
Browse latest Browse all 6937

Trending Articles