Forum Discussion

rhsou123's avatar
rhsou123
Contributor
9 years ago

Working with XML files in VBscripts

Hi all,

 

I want to use XML file to store the Static data when testing my VBS scripts.

 

I'm defining my XML file following this example

 

<?xml version="1.0"?>
<controls>
    <control id="1">
        <type>TextEdit</type>
        <name>Text1</name>
        <value>My string</value>
    </control>
    <control id="2">
        <type>Button</type>
        <name>Btn1</name>
        <value>OK</value>
    </control>
    <control id="3">
        <type>TextEdit</type>
        <name>Text2</name>
        <value>My string</value>
    </control>
    <control xmlns="CheckBoxes">
        <type>CheckBox</type>
        <name>CheckBox1</name>
        <value>True</value>
    </control>
    <control xmlns="Button2">
        <type>Button</type>
        <name>Btn2</name>
        <value>Cancel</value>
    </control>
</controls>

and I'm using this code to load it:

 

Set Doc = Sys.OleObject("Msxml2.DOMDocument.6.0")
Call Doc.load(myfilepath)

So, how can I please use the variables defined inside this file:

 

is it controls.value("variable_name") ???