Hello Everybody,

Can anybody help me, how to Extracting test data from from XML file to
an TextBox in QTP. XML file is like this,

<?xml version="1.0" encoding="UTF-8" ?>
<policy name="PSLF" schema-version="2.1.5" valid="true"
PolicyElementDescription="abc">
<NetworkProtectionSettings>
<Firewall_rules>
<ICMP_block>
<Single_IP_block>
<Policy_Name>xyz</Policy_Name>
<Source_IP>192.22.33.112</Source_IP>
<Target_IP>192.22.33.116</Target_IP>
</Single_IP_block>
</ICMP_block>
</Firewall_rules>
</NetworkProtectionSettings>
</policy>

I want to extract values in Policy_Name, Source_IP, Target_IP to
TextBoxes in a GUI, which i am automating through QTP with VBScript.

Can anybody help me in this regard.

Re: Extracting test data from from XML file to an TextBox in QTP, through vbscript by Joe

Joe
Fri Mar 21 04:13:24 CDT 2008



"Ansu" <ansuman.dash@gmail.com> wrote in message
news:37db2166-1dfa-4d2a-91ce-82973499b783@s8g2000prg.googlegroups.com...
> Hello Everybody,
>
> Can anybody help me, how to Extracting test data from from XML file to
> an TextBox in QTP. XML file is like this,
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <policy name="PSLF" schema-version="2.1.5" valid="true"
> PolicyElementDescription="abc">
> <NetworkProtectionSettings>
> <Firewall_rules>
> <ICMP_block>
> <Single_IP_block>
> <Policy_Name>xyz</Policy_Name>
> <Source_IP>192.22.33.112</Source_IP>
> <Target_IP>192.22.33.116</Target_IP>
> </Single_IP_block>
> </ICMP_block>
> </Firewall_rules>
> </NetworkProtectionSettings>
> </policy>
>
> I want to extract values in Policy_Name, Source_IP, Target_IP to
> TextBoxes in a GUI, which i am automating through QTP with VBScript.
>
> Can anybody help me in this regard.
>
I don't know QTP but to extract those values using VBScript you would do the
following steps:
Create an MSXML2.DomDocument.6.0 (if version 6.0 is not available use
version 3.0 or 4.0)
Dim oDom : Set oDom = CreateObject("MSXML2.DomDocument.6.0")
Load the XML as a file (load method) or as a string (loadXML method)
oDom.load<path to file>
Use SelectSingleNode and XPath to retrieve the desired node, e.g for
Policy_Name use
Dim oPN : Set oPN = oDom.SelectSingleNode("
/*/NetworkProtectionSettings/Firewall_rules/ICMP_block/Policy_Name")
Read the text property of the node,
Dim sPN : sPN = oPN.text

There are many similar examples in the MSXML Core Services SDK help file
which is online and comes with the component download. The examples are in
JavaScript rather than VBScript but are fairly straightforward to translate.

--

Joe Fawcett (MVP - XML)
http://joe.fawcett.name


Re: Extracting test data from from XML file to an TextBox in QTP, by Ansu

Ansu
Mon Mar 24 11:58:45 CDT 2008

On Mar 21, 2:13 pm, "Joe Fawcett" <joefawc...@newsgroup.nospam> wrote:
> "Ansu" <ansuman.d...@gmail.com> wrote in message
>
> news:37db2166-1dfa-4d2a-91ce-82973499b783@s8g2000prg.googlegroups.com...
>
> > Hello Everybody,
>
> > Can anybody help me, how to Extracting test data from from XML file to
> > an TextBox in QTP. XML file is like this,
>
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <policy name="PSLF" schema-version="2.1.5" valid="true"
> > PolicyElementDescription="abc">
> > <NetworkProtectionSettings>
> > <Firewall_rules>
> > <ICMP_block>
> > <Single_IP_block>
> > <Policy_Name>xyz</Policy_Name>
> > <Source_IP>192.22.33.112</Source_IP>
> > <Target_IP>192.22.33.116</Target_IP>
> > </Single_IP_block>
> > </ICMP_block>
> > </Firewall_rules>
> > </NetworkProtectionSettings>
> > </policy>
>
> > I want to extract values in Policy_Name, Source_IP, Target_IP to
> > TextBoxes in a GUI, which i am automating through QTP with VBScript.
>
> > Can anybody help me in this regard.
>
> I don't know QTP but to extract those values using VBScript you would do the
> following steps:
> Create an MSXML2.DomDocument.6.0 (if version 6.0 is not available use
> version 3.0 or 4.0)
> Dim oDom : Set oDom = CreateObject("MSXML2.DomDocument.6.0")
> Load the XML as a file (load method) or as a string (loadXML method)
> oDom.load<path to file>
> Use SelectSingleNode and XPath to retrieve the desired node, e.g for
> Policy_Name use
> Dim oPN : Set oPN = oDom.SelectSingleNode("
> /*/NetworkProtectionSettings/Firewall_rules/ICMP_block/Policy_Name")
> Read the text property of the node,
> Dim sPN : sPN = oPN.text
>
> There are many similar examples in the MSXML Core Services SDK help file
> which is online and comes with the component download. The examples are in
> JavaScript rather than VBScript but are fairly straightforward to translate.
>
> --
>
> Joe Fawcett (MVP - XML)http://joe.fawcett.name

Thank you very much for replying.