Read XML elements into a Combo Box 
Author Message
 Read XML elements into a Combo Box

Anyone know how to iterate through an xml file, using the additem method to
add certain main elements into a combo box (like you would if it were a
database)?

--
David



Thu, 14 Oct 2004 09:28:28 GMT  
 Read XML elements into a Combo Box
This code reads from the file c:\test.xml, and into
Combo1:

Private Sub Form_Load()

    Dim oDocument As MSXML2.DOMDocument
    Dim oRootNode As MSXML2.IXMLDOMNode
    Dim oPersons As MSXML2.IXMLDOMNodeList

    Set oDocument = New MSXML2.DOMDocument
    oDocument.Load "c:\Test.xml"
    Set oRootNode = oDocument.documentElement

    Set oPersons = oRootNode.selectNodes("persons/person")

    Dim oPerson As MSXML2.IXMLDOMNode
    For Each oPerson In oPersons
        Combo1.AddItem oPerson.Text
    Next oPerson

End Sub

The xml-file:

<?xml version='1.0' encoding='iso-8859-1'?>
<root>
 <persons>
  <person>
   Dag Sunde
  </person>
  <person>
   The Good
  </person>
  <person>
   The Bad
  </person>
  <person>
   and The Ugly
  </person>
 </persons>
</root>

Dag.


Quote:
> Anyone know how to iterate through an xml file, using the additem method
to
> add certain main elements into a combo box (like you would if it were a
> database)?

> --
> David



Fri, 15 Oct 2004 15:56:09 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Read XML elements into Combo Box

2. Read XML elements into Combo Box

3. msxml DOM: reading each element in an XML

4. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

5. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

6. Newbie: Set a combo box style(2)/Dropdown list to the first element in the list

7. Binding XML to 2 combo boxes

8. binding XML to Combo Box

9. Iterating through XML to add to combo box?

10. Read XML using VB6 DOM 4.0 with Namespaces - See Sample XML

11. enter data in a combo box based on value from another combo box

12. Limit subform combo box by selection in parent combo box

 

 
Powered by phpBB® Forum Software