Link to home
Start Free TrialLog in
Avatar of sneeri_c
sneeri_c

asked on

Delete from an XML File

I am using VB.NET 2005.

I want to delete from this XML File. If I have the following:

<?xml version="1.0" encoding="utf-8" ?>
<applicationlist>
     <app>
          <name>AC</name>
          <srcdir>c:\AC</srcdir>
      </app>
     <app>
          <name>NewAppInfo</name>
          <srcdir>c:\Info</srcdir>
      </app>
</applicationlist>

I want to delete one of the <app> sections of the xml. So I then have:

<?xml version="1.0" encoding="utf-8" ?>
<applicationlist>
     <app>
          <name>AC</name>
          <srcdir>c:\AC</srcdir>
     </app>
</applicationlist>

Thanks
Avatar of pradeepsudharsan
pradeepsudharsan

Dim doc As New XmlDocument()
        doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _
                    "<title>Pride And Prejudice</title>" & _
                    "</book>")
       
        Dim root As XmlNode = doc.DocumentElement
       
        'Remove the title element.
        root.RemoveChild(root.FirstChild)
       
        Console.WriteLine("Display the modified XML...")
        doc.Save(Console.Out)
    End Sub

ASKER CERTIFIED SOLUTION
Avatar of Nandakumar Sakthivel
Nandakumar Sakthivel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial