Today I got an working example on forum to load list items with XML
XML Structure
How can I get this Button Click event code also in xml
Need Help Please
Code:
Private Sub Form_Load()
Dim objDoc As MSXML2.DOMDocument
Dim objNodeList As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim objAttrib As IXMLDOMAttribute
' create the document object
Set objDoc = New MSXML2.DOMDocument
objDoc.async = False
' load the xml data into the document object
objDoc.Load App.Path & "\list.xml"
' get all the person nodes from the document
Set objNodeList = objDoc.selectNodes("//list1")
' loop through the node list and get the names
For Each objNode In objNodeList
' add the name to the list box
List1.AddItem objNode.Attributes.getNamedItem("name").Text
Next objNode
' clean up
Set objDoc = Nothing
End Sub
Private Sub List1_Click()
Dim objDoc As MSXML2.DOMDocument
Dim objNodeList As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
' clear the relatives listbox
List2.Clear
' create the document object
Set objDoc = New MSXML2.DOMDocument
objDoc.async = False
' load the xml data into the document object
objDoc.Load App.Path & "\list.xml"
' load the selected person node
Set objNode = objDoc.selectSingleNode("//list1[@name='" & List1.Text & "']")
' load the relatives for the selected person
Set objNodeList = objNode.selectNodes("list2")
' load the relatives into the listbox
For Each objNode In objNodeList
List2.AddItem objNode.Text
Next objNode
Set objDoc = Nothing
End Sub
Code:
<list>
<list1 name="Firefox">
<list2>Firefox 27.0 Beta 2</list2>
</list1>
</list>
Code:
Dim i As Integer, sFileName As String, sText As String
With List2
If CmdBtn(0).Caption = "&Copy" And CmdBtn(1).Caption = "&Download" Then
Set colURL = New Collection
Select Case List1.Text
Case "Firefox"
For i = 0 To .ListCount - 1
If .Selected(i) Then
Select Case .List(i)
Case "Firefox 27.0 Beta 2": colURL.Add "http://fs35.filehippo.com/4089/28513cf211d0496cb5c10382a9ae8b82/Firefox%20Setup%2027.0b4.exe"
End Select
End If
Next