| | |
Problem in Removing Node from XML using Vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 27
Reputation:
Solved Threads: 0
Dear All..
I been working on XML for the past 2 weeks and am bit new to this concept..however i have put my effort to solve my problem..
I have suceeded in creating and appending a node to a XML file..But i have problem in Removing a node in a XML file..Please see my Code below and help me to Solve this problem..
XML file... = final.xml
<TaskDetails>
<Task>
<Name>PS0002439</Name>
<Status>Open</Status>
</Task>
<Task>
<Name>PS0002440</Name>
<Satus>Open</Satus>
</Task>
</TaskDetails>
Code to Remove Node..
Am using a button to remove the node..
Button
Private Sub BnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BnStart.Click
dim Taskid1 as string
Taskid1 = "PS0002440"
Taskid1 = Taskid1.Trim
Call XmlRemove(Taskid1)
End Sub
Function
Public Sub XmlRemove(ByVal TaskId As String)
Dim Tskid, Stats As String
Tskid = TaskId.ToString.Trim
MsgBox("in")
Dim myDoc As Xml.XmlDocument = New Xml.XmlDocument
myDoc.Load("d:\final.xml")
MsgBox("file loaded")
Dim myNode As XmlNode = myDoc.SelectSingleNode("TaskDetails\Task[Name='" & Tskid & "']")
MsgBox("Node Deleted")
Dim root As XmlNode = myDoc.DocumentElement()
root.RemoveChild(myNode)
myDoc.Save("d:\final.xml")
MsgBox("Xml File Generated")
End Sub
Please Help me..i need to remove the parend node when i pass the taskid to the function..
I been working on XML for the past 2 weeks and am bit new to this concept..however i have put my effort to solve my problem..
I have suceeded in creating and appending a node to a XML file..But i have problem in Removing a node in a XML file..Please see my Code below and help me to Solve this problem..
XML file... = final.xml
<TaskDetails>
<Task>
<Name>PS0002439</Name>
<Status>Open</Status>
</Task>
<Task>
<Name>PS0002440</Name>
<Satus>Open</Satus>
</Task>
</TaskDetails>
Code to Remove Node..
Am using a button to remove the node..
Button
Private Sub BnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BnStart.Click
dim Taskid1 as string
Taskid1 = "PS0002440"
Taskid1 = Taskid1.Trim
Call XmlRemove(Taskid1)
End Sub
Function
Public Sub XmlRemove(ByVal TaskId As String)
Dim Tskid, Stats As String
Tskid = TaskId.ToString.Trim
MsgBox("in")
Dim myDoc As Xml.XmlDocument = New Xml.XmlDocument
myDoc.Load("d:\final.xml")
MsgBox("file loaded")
Dim myNode As XmlNode = myDoc.SelectSingleNode("TaskDetails\Task[Name='" & Tskid & "']")
MsgBox("Node Deleted")
Dim root As XmlNode = myDoc.DocumentElement()
root.RemoveChild(myNode)
myDoc.Save("d:\final.xml")
MsgBox("Xml File Generated")
End Sub
Please Help me..i need to remove the parend node when i pass the taskid to the function..
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Timing problem? Variable does not always update
- Next Thread: vb.net 08 Reading data from multiple reg keys
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp google hardcopy image images isnumericfuntioncall login math memory mobile ms mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox1 port print printpreview problemwithinstallation project record reports" reuse save savedialog searchbox serial soap storedprocedure string tcp temp text textbox timer toolbox trim updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf





