Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Genaralised code for checking the comparision of two xml files having child nodes.
#2
Not Solved
Try the code below to compare two xml files
Code:
Set oXML1 = CreateObject("Msxml2.DOMDocument")
oXML1.load("<<Your first File Path >>")
Set oXML2 = CreateObject("Msxml2.DOMDocument")
oXML2.load("<<Your Second File Path >>")
Set XMLElements1= oXML1.DocumentElement.ChildNodes
Set XMLElements2= oXML2.DocumentElement.ChildNodes
If XMLElements1.length=XMLElements2.length Then

  msgbox "Child Nodes - Equal"

   For i = 0 to XMLElements1.length-1

       If XMLElements1.item(i).Text <> XMLElements2.item(i).Text Then
         msgbox "Elements Not same- XML files are not equal "
         Exit for
     End If
  Next
msgbox "Elements  same- XML files are equal "
else
    msgbox  "Child Nodes - Not Equal- XML files are not equal"
End If

Alternately this can be done using XMLUtils as well
Code:
xmlFile1 = "<<Your first File Path >>"
xmlFile2 = "<<Your second File Path >>"

Set oXML1 = XMLUtil.CreateXML()
Set oXML2 = XMLUtil.CreateXML()

oXML1.LoadFile (xmlFile1)
oXML2.LoadFile (xmlFile2)

CompareResult = oXML1.compare(oXML2, ResultsXML)

If CompareResult = 1 THEN
    MsgBox "XML files are equal"
Else
    MsgBox "XML files are not equal"
END IF
    ResultsXML.savefile (“c:\results.xml”)

Reply


Messages In This Thread
RE: Genaralised code for checking the comparision of two xml files having child nodes. - by Saket - 11-06-2009, 11:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Please explain how can i expand the nodes in UFT rajeevk7 0 3,125 07-04-2017, 03:47 PM
Last Post: rajeevk7
  SwfTreeview - Color validation for child item YogeshCallappa 0 2,115 11-10-2016, 04:55 PM
Last Post: YogeshCallappa
  Driver Script to control child scripts sumanhyd 1 3,010 07-26-2016, 07:06 PM
Last Post: Ankesh
  UFT 12.50 unable to recognize child objects from a Dialog Class in Firefox jesusisaac 1 3,627 08-20-2015, 11:39 PM
Last Post: ADITI1992
  Child object shwetakondekar 0 2,050 07-01-2015, 03:28 PM
Last Post: shwetakondekar

Forum Jump:


Users browsing this thread: 1 Guest(s)