Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

18539 Posts in 4847 Topics- by 32743 Members - Latest Member: watty
 

AdvancedQTP forums have been nominated as a finalist in ATI’s 2nd annual automation honors awards!

We’d like to thank you for your continued support and participation, and urge you to hurry and vote.

Make you voice count! 


Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Verify Element that comes repeatedly    (Read 286 times)
Ichan Khan
Active User
**
Offline Offline

Posts: 81


« on: March 22, 2010, 07:15:45 AM »

Hi.

Let say Your response is like this,
<Root>
 <Test>
  <Leaf>
  <value1>Test1</value1>
  <value2>Test2</value2>
  </Leaf>
  </Test>
  <Test>
  <Leaf>
  <value1>Test3</value1>
  <value2>Test4</value2>
  </Leaf>
  </Test>
</Root>

How this thngs will verified.. since the value1 has now 2 differnt value.
Logged
Ichan Khan
Active User
**
Offline Offline

Posts: 81


« Reply #1 on: March 30, 2010, 02:02:15 PM »

Code is done will paste it later, just modified the existing code of stephan...
Logged
Ichan Khan
Active User
**
Offline Offline

Posts: 81


« Reply #2 on: April 02, 2010, 08:33:53 AM »

Here you go: Modified according to my need.
Function validateXMLResponse(objDictionary)
Dim aryLoadPassFail(15)
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.loadXML(objDictionary.Item("XMLResponse"))
'Check XML syntax
If (xmlDoc.parseError.errorCode <> 0) Then
 Set myErr = xmlDoc.parseError
       objDictionary.Item("XMLResponseResult") = "Failed"
         objDictionary.Item("XMLResponseResultDetails") = "ERROR: " & myErr.reason
      Set validateXMLResponse = objDictionary
   Exit Function
End If
Set root = xmlDoc.documentElement
arrAllKeys = objDictionary.Keys
arrAllValues = objDictionary.Items
For i = 0 to Ubound(arrAllKeys)
 
    'Only process #-type parameters
   If Left(arrAllKeys(i),1) = "#"   Then
       strParameterElementName = arrAllKeys(i)
      'msgbox   strParameterElementName
      strParameterElementValue = arrAllValues(i)
      strParameterElementName = Right(strParameterElementName,Len(  strParameterElementName )-1)        
      arrParameterElementValue  = Split(  strParameterElementValue,",")
Set objChildNodes = root.getElementsByTagName(strParameterElementName)
 numberof=objChildNodes.length
For k = 0 to objChildNodes.length
For m=k To Ubound(arrParameterElementValue)
   strParameterElementValueExpected=arrParameterElementValue(m)
'msgbox"This is the expected value"& strParameterElementValueExpected
   strElementValueInNode =objChildNodes.item(k).Text   
'msgbox"This is the actual value" &strElementValueInNode
 bElementValueExist = (StrComp( strElementValueInNode,strParameterElementValueExpected, vbTextCompare)="0")
If bElementValueExist  = "True"  Then   
      objDictionary.Item("XMLResponseResult") = "Passed"       
      Else
   objDictionary.Item("XMLResponseResult") = "Failed"
   objDictionary.Item("XMLResponseResultDetails") ="Element Value Is Not Found in the Response"
   Set validateXMLResponse = objDictionary
   Exit Function
   End if      
   k=k+1 
   Next
Next
'Return
End if
Next
Set validateXMLResponse = objDictionary
'Clean up
Set root = Nothing
Set xmlDoc = Nothing
End Function
Logged
Pages: [1]   Go Up
Print
Jump to: