8 апреля 2008 г. 9:47
i ve an xml file in the format
I want to delete the node whose ID is "B" ... how can i do this ??
The code that i wrote is
Dim xpathquery as String
Dim doc as new XmlDocument
Dim selectedNode,main_node as XmlNode
xpathquery = "/Root[ID='" & txtID.Text & "']"selectedNode = doc.SelectSingleNode(xpathquery)
main_node = doc.SelectSingleNode(xpathquery)
when i tried executing this code i m getting the error "the node to be removed is not a child of this node " ... how can i correct this error ?? Can anybody help me ??
Any help appreciated ...
Thanx in Advance
8 апреля 2008 г. 11:27
Your XPath expression is not correct, if I understand you correctly that you want to remove the 'ID' element.
Here is a sample:Code SnippetDim doc As New XmlDocument()
doc.Load("file.xml") Dim node As XmlNode = doc.SelectSingleNode("Root/ID[. = 'B']") If node IsNot Nothing Then
' Save change here or later e.g.
13 апреля 2012 г. 9:45I have the same problem. I have converted my XML into a table by VB. it has the ability to add new data into the table and it will also added to my XML. But I want to add the function for removing a row of data which are coming from my XML. but I don't know how can I modify your code to do this? can you help me?