Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Compare two XML files, when one file is Uploaded File and the Other is Exporte
#4
Not Solved
Hi Venkat,
Thanks for Replying. I used the same Quote for xml comparision, but in our portal there are some mandatory fields and automatically it creates XML tags when a file is exported.Now if a file is uploaded with invalid data for the field which is mandatory and if exported ,a tag is being generated with out a value .Now if i add a check point for xml comparision it must show the difference in the values.
If there is one difference between the uploaded and Exptoreted file, it is showing the difference. But it is not working fine when there are multiple differences present.

Code used in test case:---------
Code:
Dim description, filepath
Set xmlDoc1 = CreateObject("Msxml2.DOMDocument")
xmlDoc1.load("C:\Documents and Settings\Ramakrishna\QTP\Qtp Tests\EzLynx Portal\Test Data\Upload\Auto.xml")
Set xmlDoc2 = CreateObject("Msxml2.DOMDocument")
xmlDoc2.load("C:\Documents and Settings\Ramakrishna\QTP\Qtp Tests\EzLynx Portal\Test Data\ExportFile\App1.xml")
Set ElemList1= xmlDoc1.DocumentElement.ChildNodes
Set ElemList2= xmlDoc2.DocumentElement.ChildNodes
If ElemList1.length=ElemList2.length Then
    Else
          For i = 0 to ElemList1.length-1
                 If ElemList1.item(i).Text=ElemList2.item(i).Text Then
'             msgbox
                     Reporter.ReportEvent micPass,"Checking for Child Elements","child element:"&i &" is same in both XML files"
                 Else
'             msgbox
                     Reporter.ReportEvent micFail,"Checking for Child Elements","child element:"& i &" is not same in both the XML files, In XML file 1, The valueis: "& ElemList1.item(i).Text &" and In XML file 2, The valueis:"&ElemList2.item(i).Text
'                msgbox  ElemList1.item(i).nodeName
'======Checking for the Particular child for which there is a difference======
Code:
Set ElemChildList1 = ElemList1.item(i).ChildNodes
                Set ElemChildList2 = ElemList2.item(i).ChildNodes
'                msgbox ElemChildList.length
                For J = 0 to ElemChildList1.length-1
                    If  ElemChildList1.item(J).Text=ElemChildList2.item(J).Text Then
                         Reporter.ReportEvent micPass,"Checking for Error Field","There is no Difference in the Files"
                         Else
                         Reporter.ReportEvent micFail,"Checking for Error Field","child element:"& ElemChildList1.item(J).nodeName&"is not same in both the XML files, In XML file 1, The value is:"&ElemChildList1.item(J).Text&"and In XML file 2, The value is:"&ElemChildList2.item(J).Text
                         End If
                    Next
             End If
             Next
             End If
Reply


Messages In This Thread
RE: How to Compare two XML files, when one file is Uploaded and the Other is Exporte - by Ganta - 10-26-2009, 03:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  File Chooser on Chrome doesn't work - UFT 15.0.1 Nenna Rosa 1 3,674 10-31-2020, 01:16 PM
Last Post: Ankur
  File Pointers Reset When Using Subroutines zunebuggy 0 874 08-19-2020, 07:45 PM
Last Post: zunebuggy
  How to export the output value of a webedit object to a new excel file. mounika6677 1 1,540 04-14-2019, 05:18 PM
Last Post: mounika6677
  Invalid file error importing xls file Makhado 0 1,431 10-04-2018, 04:33 PM
Last Post: Makhado
  Access not saved excel file randhirsinghskhn 0 1,046 09-04-2018, 07:26 AM
Last Post: randhirsinghskhn

Forum Jump:


Users browsing this thread: 4 Guest(s)