cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
abby27
Level 4

Populate Combobox from a XML File using VBScript

Can somebody please post some code to show how to fill/populate a COMBOBOX with values gotten from a XML file. I am trying to do this in a CustomAction

My XML file is in the following format



REGION1
10


REGION2
20


If you have a solution how to do this from a TEXT file, please share it.
Appreciate all your responses
Thanks in advance
Labels (1)
0 Kudos
(2) Replies
abby27
Level 4

I solved it myself. Posting here so it could be of use to someone ...

Here is the VBScript Code to parse my xml file, which is located in the same directory as my setup.exe

This script is in a CustomAction which I hooked up to be invoked when the 'Next' button of the previous dialog is clicked.

Set MsiDb = Session.Database
Set MsiInstall = Session.Installer
Set MsiView = MsiDb.OpenView("SELECT * FROM ComboBox")

index = 1


strFilePath = Session.Property("SETUPEXEDIR")

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load(strFilePath & "\regions.xml")

strQuery = "/Regions/Region"
Set objNodeList = xmlDoc.selectNodes(strQuery)

For Each objNode in objNodeList
strRegionName = objNode.SelectSingleNode("RegionName").Text
strRegionValue = objNode.SelectSingleNode("RegionValue").Text

'Now Populate the ComboBox with the strRegionName and strRegionValue items
MsiRecord = MsiInstall.CreateRecord(4)
MsiRecord.StringData(1) = "REGION" 'The Name of the Property
MsiRecord.IntegerData(2) = index 'The Sequence/Order in the ComboBox
MsiRecord.StringData(3) = strRegionValue 'VALUE of the Item in the List
MsiRecord.StringData(4) = strRegionName 'TEXT to be displayed to the user
Call MsiView.Execute(MsiRecord)
Call MsiView.Modify (7, MsiRecord)
'MsgBox strRegionName & vbCr & vbLf & strRegionValue & vbCr & vbLf
index =index + 1
Next

Call MsiView.Close

'Cleanup
Set xmlDoc = Nothing

Thnx
0 Kudos
proactis
Level 4

I tried this script and can't get it to work
0 Kudos