How do I read an XML file into a combo box ???
Printable View
How do I read an XML file into a combo box ???
Load it into a Dataset and then loop the column you want into the combo box!
The below code doesn't work. What am I doing wrong ?
Dim ds As New DataSet
ds.ReadXml("c:\\tirebrand.xml")
'cb1.DisplayMember = "host_Text"
'cb1.DataSource = ds.Tables("host")
neither this.
Dim dom As New Xml.XmlDocument
dom.Load("c:\\tirebrand.xml")
cb1.Items.Clear()
For Each node As Xml.XmlNode In dom.SelectNodes("host")
cb1.Items.Add(node.InnerText)
Next
thanks.
My XML file looks like:
Code:</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
- <BRAND>
<BRAND_CODE>01</BRAND_CODE>
<BRAND>AVON</TIRE_BRAND>
</BRAND>
- <BRAND>
<BRAND_CODE>02</BRAND_CODE>
<BRAND>LANCOME</TIRE_BRAND>
</BRAND>
and I have to read this into 2 combo boxes that is brandcode and brandname
and when I tried something like
VB Code:
Dim reader As New XmlTextReader("C:\tirebrand.xml") While reader.Read() cb1.Items.Add(reader.Name) End While
it populates the name tags like "BRAND", "BRAND_CODE", "BRAND"... how do I read the brand code and brand name data and not the tag?