Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exract data from XML using QTP
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hello,

I am currently trying to extract data from an XML file using QTP. This is fairly new to me so please bear with me. The XML file contains many "Operation" nodes. From these nodes, I want to filter the appropriate node based on Operation ID and Operation Type. After that, I want to capture all of the Condition IDs for this Node. I would appreciate greatly any information I can use to start and build on.

Here is my sample code that need revision:
Code:
Set xmlDoc = XMLUtil.CreateXML()
Set objNode=xmlDoc.selectSingleNode(./OPERATION[@ID=REMOVEEQPT]")

<OPERATION ID="INSTALLEQPT" TYPE="FIX" CONFIRMATION="">
        <ATTRIBUTES>
            <ATTRIBUTE ID="EQPTTYPE"/>
        </ATTRIBUTES>
        <CONDITIONS>
            <CONDITION ID="UPGRADEABLE"/>
            <CONDITION ID="EQUIPMENT_IS_OK"/>
        </CONDITIONS>
    </OPERATION>
<OPERATION ID="REMOVEEQPT" TYPE="UNINSTALL" CONFIRMATION="">
        <ATTRIBUTES>
            <ATTRIBUTE ID="EQPTTYPE"/>
            <ATTRIBUTE ID="EQPTCOLOR"/>
            <ATTRIBUTE ID="EQPTAGE"/>
        </ATTRIBUTES>
        <CONDITIONS>
            <CONDITION ID="PROVISIONED"/>
            <CONDITION ID="NOT_ON"/>
            <CONDITION ID="CALL_HELP"/>
                   </CONDITIONS>
    </OPERATION>
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
Code:
Set oXML = CreateObject("Microsoft.XMLDOM")
' capture all condition ids
Set oConditionIds = oXML.getElementsByTagName("CONDITION ID")

For iCnt=0 to oConditionIds.Length-1
     Print oConditionIds.Item(iCnt).nodeName & "::" & oConditionIds.Item(iCnt).text
Next

Test Automation and QTP - Excel with Ease provides a good reference on working with xml files
Reply
#3
Solved: 11 Years, 4 Months, 3 Weeks ago
Code:
Set oXML = CreateObject("Microsoft.XMLDOM")
' capture all condition ids
Set oConditionIds = oXML.getElementsByTagName("CONDITION ID")

For iCnt=0 to oConditionIds.Length-1
     Print oConditionIds.Item(iCnt).nodeName & "::" & oConditionIds.Item(iCnt).text
Next

Test Automation and QTP - Excel with Ease provides a good reference on working with xml files
Reply
#4
Solved: 11 Years, 4 Months, 3 Weeks ago
Thanks Rajeevszone. I suspected as much. Much appreciated.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading XML Data from a WebPage shaan.mishra87@gmail.com 1 2,251 09-28-2016, 09:16 PM
Last Post: supputuri
  Getting an 'Error in XML document' Error when submitting web services XML luckyexpert 0 3,156 08-20-2013, 10:23 PM
Last Post: luckyexpert
  XML Data read and extract output in an array SweetyChowdhury 9 7,862 05-10-2013, 03:05 PM
Last Post: SweetyChowdhury
  XML input data validation with data in oracle tables using webservice smtripathi99 0 2,432 12-11-2012, 01:32 PM
Last Post: smtripathi99
  Need URGENT help how to read xml string / xml tag value in web page using QTP VQTP 2 5,961 04-16-2009, 02:27 AM
Last Post: VQTP

Forum Jump:


Users browsing this thread: 1 Guest(s)