07-02-2010 01:13 AM - last edited on 05-19-2013 10:32 PM by maikoro
I wanna run the following scenario in QTP:
Compare two XML files and report the mismatch(if any).
P.S. this thread has been moved from Quality Center Support and News Forum to Unified Functional Testing (formerly QTP) News and Support Forum - Hp Forum moderator
07-02-2010 09:10 AM
You have two options.
#1 You could script it to open the .XML file in MS Word then within MS Word select the Tools menu, click Compare and Merge Documents.
#2 You could also try...
Public Function CompareFiles (FilePath1, FilePath2)
Dim FS, File1, File2
Set FS = CreateObject(â Scripting.FileSystemObjectâ )
If FS.GetFile(FilePath1).Size <> FS.GetFile(FilePath2).Size Then
CompareFiles = True
Set File1 = FS.GetFile(FilePath1).OpenAsTextStream(1, 0)
Set File2 = FS.GetFile(FilePath2).OpenAsTextStream(1, 0)
CompareFiles = False
Do While File1.AtEndOfStream = False
Str1 = File1.Read(1000)
Str2 = File2.Read(1000)
CompareFiles = StrComp(Str1, Str2, 0)
If CompareFiles <> 0 Then
CompareFiles = True
I hope this helps.
05-13-2013 08:58 AM
I am trying the Compare method of QTP to compare two XML files
However, I want to make this method more 'clever'
To be more precise,
If the first XML file has the a value 2 and the second XML file has the value 2.0, then the comparison fails.
However, 2 and 2.0 is the same actual number.
Could you please let me know your thoughts on this?
05-13-2013 11:23 AM
We used a third party tool called Beyond Compare for comparison of XML files. Within the QTP script, we gave the WShell commands necesary to open Beyond Compare with the two file names. We then retrieved the pass/fail on the comparison. If failed, we screen captured the Beyond Compare screen showing the difference(s).
That was at a previous company and I no longer have access to the actualy code written to perform these functions.
05-14-2013 02:18 AM
Thank you a lot for your reply,
I will try this for sure
However, Since I will give the scripts to our client, I cannot 'force them' to use a third party application
I have to find solution into QTP