Populating Listbox from xml file

rkeslar75

Member
Joined
Oct 11, 2007
Messages
5
Programming Experience
5-10
Could anyone point me to a good example of populating a listbox with data from an xml file?

I'm working with a winform in vb.net.

Thanks
 
If the data structure fits you can load the Xml to a Dataset and set DataSource and DisplayMember:
VB.NET:
Dim ds As New DataSet
ds.ReadXml("http://www.vbdotnetforums.com/external.php?type=rss2")
ListBox1.DataSource = ds.Tables("item")
ListBox1.DisplayMember = "title"
Else you can for example use XmlDocument to get nodes and add the items with the text:
VB.NET:
Dim doc As New Xml.XmlDocument
doc.Load("http://www.vbdotnetforums.com/external.php?type=rss2")
For Each node As Xml.XmlNode In doc.SelectNodes("rss/channel/item/title")
    ListBox1.Items.Add(node.InnerText)
Next
 
Back
Top