Fore more QTP Realtime scripts, visit www.ramupalanki.com

Dim description, filepath
Set xmlDoc1 = CreateObject(“Msxml2.DOMDocument”)
xmlDoc1.load(“C:Documents and Settingsmohan.kakarlaDesktop1.xml”)’file 1
Set xmlDoc2 = CreateObject(“Msxml2.DOMDocument”)
xmlDoc2.load(“C:Documents and Settingsmohan.kakarlaDesktop2.xml”)’file 2
Set ElemList1= xmlDoc1.DocumentElement.ChildNodes
Set ElemList2= xmlDoc2.DocumentElement.ChildNodes
If ElemList1.length=ElemList2.length Then’ check weather both xml file has same
number of childnodes
msgbox “Both XML files have same number of Child nodes”

For i = 0 to ElemList1.length-1

If ElemList1.item(i).Text=ElemList2.item(i).Text Then
msgbox “child element:”&i &” is same in both XML files”
Else
msgbox “child element:”& i &” is not same in both XML files, In XML file 1, The
valueis:”&ElemList1.item(i).Text &” and In XML file 1, The value

is:”&ElemList2.item(i).Text
End If
Next

Qtp compare two xml files

  • 1.
    Fore more QTPRealtime scripts, visit www.ramupalanki.com Dim description, filepath Set xmlDoc1 = CreateObject(“Msxml2.DOMDocument”) xmlDoc1.load(“C:Documents and Settingsmohan.kakarlaDesktop1.xml”)’file 1 Set xmlDoc2 = CreateObject(“Msxml2.DOMDocument”) xmlDoc2.load(“C:Documents and Settingsmohan.kakarlaDesktop2.xml”)’file 2 Set ElemList1= xmlDoc1.DocumentElement.ChildNodes Set ElemList2= xmlDoc2.DocumentElement.ChildNodes If ElemList1.length=ElemList2.length Then’ check weather both xml file has same number of childnodes msgbox “Both XML files have same number of Child nodes” For i = 0 to ElemList1.length-1 If ElemList1.item(i).Text=ElemList2.item(i).Text Then msgbox “child element:”&i &” is same in both XML files” Else msgbox “child element:”& i &” is not same in both XML files, In XML file 1, The valueis:”&ElemList1.item(i).Text &” and In XML file 1, The value is:”&ElemList2.item(i).Text End If Next