November 15th, 2010, 04:11 AM
Read simple xml file
Let's say I have a very simple xml file, something like:
Nodes are always the same, only the value will change. How do I read the value of the node, e.g. into a textbox? I'm using VB10 to write this file.
<Date>2010, Nov 14</Date>
<ProjectAddress>Here and there</ProjectAddress>
November 15th, 2010, 10:46 PM
November 16th, 2010, 12:31 AM
VB.NET indeed... I of course tried to search a solution, but all I found was a bit overkill for such a simple task. I scribbled this, which actually works OK for my purposes.
Dim doc As XmlDocument = New XmlDocument
doc.Load(folderDlg.SelectedPath & "\" & "settings.xml")
Dim roots As XmlElement = doc.DocumentElement
' and then populate textboxes...
txtProjectName.Text = roots.SelectSingleNode("/root/ProjectName").InnerText
' and so on...