Removing elements and attributes

Elements may be removed from a document by selecting the node, then calling the RemoveChild method on the parent:

[Xml]$xml = @" 
<?xml version="1.0"?> 
<list type='numbers'> 
    <name>1</name> 
    <name>2</name> 
    <name>3</name> 
</list> 
"@ 
$node = $xml.SelectSingleNode('/list/*[.="3"]') 
$null = $node.ParentNode.RemoveChild($node) 

The RemoveAll method is also available; however, this removes all children (and attributes) of the selected node.

Attributes are also easy to remove from a document:

$xml.list.RemoveAttribute('type') 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.229.113