Help with deleting record in xml file
Posted on 2011-10-12
I'm trying to delete records in my link.xml file based on the value of the Link_ID. I've tried hard coding the value of Link_ID (3) to test the code, but it doesn't delete the record where Link_ID = 3, can you please help me fix this problem.
Dim an As String
an = MsgBox("Are you sure you want to Delete this record?", MsgBoxStyle.YesNo, "Warning before Attempting to Save Data")
Dim x As Integer
x = 3
If an = MsgBoxResult.Yes Then
Dim xml As String = LinkStream.InnerXml
Dim newline As String = Environment.NewLine
' Dim replacement As String = "<Link><ReceiverID>" & x & "</ReceiverID><DonorID>" & DropDownList1.Text & "</DonorID></Link>"
Dim replacement As String = "<Link><Link_ID>" & 3 & "</Link_ID></Link>"
LinkStream.InnerXml = xml.Replace(replacement, "")
Dim cnt As Integer = LinkStream.SelectNodes("Root/Link").Count
'txtTotalRecords.Text = cnt
MsgBox("Record was deleted")
If an = MsgBoxResult.No Then
MsgBox("Record was not deleted")