Results 1 to 4 of 4

Thread: [RESOLVED] How to read XML file into a combo box ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    25

    Thumbs up [RESOLVED] How to read XML file into a combo box ?

    How do I read an XML file into a combo box ???
    Last edited by anin; Mar 4th, 2005 at 03:57 PM. Reason: [RESOLVED]

  2. #2
    Hyperactive Member
    Join Date
    Feb 2003
    Posts
    263

    Re: How to read XML file into a combo box ?

    Load it into a Dataset and then loop the column you want into the combo box!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    25

    Re: How to read XML file into a 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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    25

    Re: How to read XML file into a combo box ?

    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:
    1. Dim reader As New XmlTextReader("C:\tirebrand.xml")
    2.         While reader.Read()
    3.             cb1.Items.Add(reader.Name)
    4.         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?
    Last edited by anin; Mar 4th, 2005 at 01:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width