Hi again gurus , I am currently working on a form which contains a listbox and a few text fields. I am using an xml file that looks like this:
<?xml version="1.0"?>
<Sessionlist>
<session name="rx30">
<sessionname>rx30</sessionname>
<sessionhost>192.168.0.254</sessionhost>
<sessionuser>user</sessionuser>
<sessionpass>pass</sessionpass>
</session>
<session name="rx30extra">
<sessionname>rx30extra</sessionname>
<sessionhost>192.168.0.254</sessionhost>
<sessionuser>user</sessionuser>
<sessionpass>pass</sessionpass>
</session>
</Sessionlist>
I am able to populate the listbox with the sessionname node by using xmltextreader by doing the following:
What I want to be able to do is click an item and have the text fields populate with specific node information. I have read numerous tutorials, and read some info on this - but i cant get it to work and am getting fustrated. I have tried the following with no success:Code:Dim xmlfile As String = "c:\sessionlist.xml"
Dim xmldoc As New XmlDocument
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim openfile As New XmlTextReader(xmlfile)
While openfile.Read
If openfile.Name = "sessionname" AndAlso openfile.NodeType = XmlNodeType.Element Then
ListBox1.Items.Add(openfile.ReadString)
End If
End While
openfile.Close()
End Sub
Please help if you can - i know this may be a newbie question, but I am just that.. a newbie! Thanks in advance.Code:Dim node As XmlNode = xmldoc.SelectSingleNode( _
"session/Sessionlist/session[" & position & "]")
sessionname.Text = node.SelectSingleNode("@name").InnerText
hostname.Text = node.SelectSingleNode("sessionhost").InnerText
userbox.Text = node.SelectSingleNode("sessionuser").InnerText
