Part of the problem is that XML is not valid.
Naming Elements and Attributes
Element names cannot contain spaces.
Assuming valid XML element names, i.e.: First_group, Second_group, the following code removes all children from Second_group
Dim doc As New XmlDocument() Dim nodes As XmlNodeList doc.Load("c:\temp\node.xml") nodes = doc.SelectNodes("/group/Second_group") For Each node As XmlNode In nodes If node IsNot Nothing Then node.RemoveAll() doc.Save("c:\temp\node.xml") End If Next
Or LINQ to XML:
Dim doc As XDocument = XDocument.Load("c:\temp\node.xml") doc.Root.Element("Second_group").Elements("Name").Remove() doc.Save("c:\temp\node.xml")
source share