Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with removing data element

Hi,

How do you remove a data element from a xml file using VB.NET?

Thanks,

Victor
Avatar of Randy Poole
Randy Poole
Flag of United States of America image

Dim doc As New XmlDocument()
doc.Load("file.xml")
Dim n As XmlNode = doc.SelectSingleNode("xpath expression")
If n IsNot Nothing Then
  n.ParentNode.RemoveChild(n)
  doc.Save("file.xml")
End If
set doc=nothing

Open in new window

replace "file.xml" with the name of the file you want to alter, and change the "xpath expression" to select the node you would like to remove
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
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
Avatar of Victor  Charles

ASKER

Thank You.