Here's a quick example that might get you started. For starters prepare
the following xml document using notepad (or whatever) and save it on
your desktop as test.XML
<BaseNode>
<TargetNode>ChangeMe</TargetNode>
<TargetNode>DontChangeMe</TargetNode>
</BaseNode>
Ok, then here's the code I wrote real quick to look for a specific node
and change it's value.
Imports System.Xml
Module Module1
Sub Main()
' Change the below to match the file's directory
Dim dir As String = "C:\Documents and
Settings\username\Desktop\test.XML"
Dim doc As New XmlDocument
doc.Load(dir)
Dim nodelist As XmlNodeList =
doc.GetElementsByTagName("TargetNode")
For Each node As XmlNode In nodelist
If node.InnerText = "ChangeMe" Then
node.InnerText = "OKIwill"
End If
Next
doc.Save(dir)
End Sub
End Module
Hope that helps!
Thanks,
Seth Rowe
Major Aardvark wrote:
Hi
I have read in an single node and it's list of values into a CheckedListBox
so that I can select which values I actually want to have in the node.
The question I now have is how can I write just this one node and its values
back to the original XML file, replacing the data that is already there?
Thanks for any suggestions you have!