Please help me with the code requirement.I need to display the file name along with mismatch text when compare the 'n' number of xml files.

I have the code to compare and output the text of the mismatching files but my requirement is just display the name of mismatch file along with the mismatch text.

Please update the below function to meet my requirement.

Many thanks

Function xmlcomp()

actualfolder = environment("actfld")

expectedfolder = environment("expfld")

resultfolder = ""

Dim fso, f, fc, f1, ln

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder(expectedfolder)

Set fc = f.Files

For Each f1 in fc

expectedfile = expectedfolder +

actualfile = actualfolder + f1.Name

Set oXML1 = CreateObject("Msxml2.DOMDocument")

Set oXML2 = CreateObject("Msxml2.DOMDocument")

Set XMLElements1= oXML1.DocumentElement.ChildNodes
Set XMLElements2= oXML2.DocumentElement.ChildNodes

If XMLElements1.length=XMLElements2.length Then

reporter.ReportEvent micPass, "Child Nodes - Equal", "Pass"

For i = 0 to XMLElements1.length-1

If XMLElements1.item(i).Text <> XMLElements2.item(i).Text Then

reporter.ReportEvent micFail, " Elements are not same- XML files are not equal", "Fail""C:\ERSTest\QTP\QTP_TASK\Result\tempfil e.txt")

errorfile = "C:\ERSTest\QTP\QTP_TASK\Result\errorfile.txt"

Set TempFile= fso.OpenTextFile("C:\ERSTest\QTP\QTP_TASK\Result\t empfile.txt", 1, True)

lne = TempFile.ReadAll

err_update "************************************************* *******************", errorfile

err_update lne, errorfile

err_update "************************************************* *******************", errorfile


fso.DeleteFile("C:\ERSTest\QTP\QTP_TASK\Result\tem pfile.txt")

end if


reporter.ReportEvent micPass, "Elements same- XML files are equal", "Pass"


reporter.ReportEvent micFail, "Child Nodes - Not Equal- XML files are not equal", "Fail"

End If


Set f= nothing

Set fso = nothing

End Function

Public Function err_update(errstring, errorfile)

dim fileSource, MyFile
Set fileSource = CreateObject("Scripting.FileSystemObject")
Set MyFile = fileSource.OpenTextFile(errorfile, 8, True)
MyFile.WriteLine Date & " " & Time & " : " &errstring

End Function