Hi there,
I have an XML file and structured like this:
Code:<?xml version="1.0" encoding="utf-8"?> <applications> <app id="b461ae4a" valid="1" company="Orange Inc." appname="None" user="tommy" description="Test" note="None" /> <app id="1c94395b" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" /> <app id="d65k274p" valid="0" company="Lemon Inc." appname="None" user="admin" description="Test" note="None" /> </applications>
And I wish to be able to populate / enumerate field by filed to List Box, but I'm missing something out and my loop is getting errors:
also tried like this:Code:Dim xmlDoc As Object Dim xmlNode As Object Dim xmlNodes As Object Dim stXmlFile as String Dim itCnt As Integer stXmlFile = "C:\apps.xml" Set xmlDoc = CreateObject("Microsoft.XMLDOM") xmlDoc.async = "False" If Not xmlDoc.Load(stXmlFile) Then Set xmlNodes = Nothing Set xmlDoc = Nothing Debug.Print "Error" Exit Sub End If For itCnt = 0 To xmlDoc.selectNodes("//applications").length ListBox.AddItem xmlDoc.selectNodes("//applications//app").Item(itCnt).selectSingleNode("id").Text ListBox.AddItem xmlDoc.selectNodes("//applications//app").Item(itCnt).selectSingleNode("valid").Text ListBox.AddItem xmlDoc.selectNodes("//applications//app").Item(itCnt).selectSingleNode("company").Text ' ... etc... Next itCnt
But without any luck.Code:Set xmlNodes = xmlDoc.SelectNodes("//applications//app") For Each xmlNode In xmlNodes ListBox.AddItem xmlNodes.getAttribute("id") ListBox.AddItem xmlNodes.getAttribute("valid") ListBox.AddItem xmlNodes.getAttribute("company") Next
Any help would be highly appreciated!
Kind regards,
Viktor




Reply With Quote
