Text File compare in “WDIFF” style (QTP, VBScript, XML, XSL) – Instructions and XSL script

Posted by Albert Gareev on May 27, 2009 | Categories: How toText DataXML Data

Original date: N/A
The post has been mostly recompiled from the comments.

Displaying Text File comparison results in an embedded report.

Refer to Text File Compare functions used to see how XML file is generated.

Sample requirements to show comparison results stored in XML as a web-page (HTML).

1. Show file stats saved in xml file.
2. Show original text line by line stored in xml file.
3. Highlight mismatching words.


If you want to go over implementation steps and XSL script, please refer to Text File Compare Report example (XML, XSL, HTML)

If you just want to use files, please follow the instructions below.

Sample files.

xml-xsl files

File instructions: Download, Save. Rename to “sample.rar”. Extract 2 files: “1+.xml” and “showdiff.xsl”. Save files to “C:\Temp\”.

File descriptions.

“1+.xml” – Text File Compare results file with XSL parser call.
This is the same file as in the previous post except of the first line added that points to XSL parser script.

“showdiff.xsl”  – XSL parser script.

Now, I used to get a lot of questions regarding file comparison examples I posted.

In order to improve “tech support” for the TextFileCompare function, I put some additional information and some questions you need to answer when you’re asking me for help.

1. Please provide a short block of your code that uses the function.

2. Make sure you follow the parameters declaration and requirements.

ByVal sFile1 – this is the “expected result file”.
Full file path must be provided.
File must be existing and accessible.

ByVal sFile2 – this is the “actual result file”.
Full file path must be provided.
File must be existing and accessible.

ByVal sOutputFolder – this is the FOLDER where you want the output xml file (containing mismatch report) to be created.
Full folder path must be provided.
Folder must be existing and accessible.

ByVal objParameter – this is the Dictionary of optional parameters.
Just pass “Nothing” for this version of the function.
The higher scale File Compare I use according to my Business Test Requirements allows customized comparing with the flags like “Ignore Case”, “Skip Empty Lines”, “Compare As Numbers”, “Ignore Rounding”.
To simplify the code I left only the core word-by-word comparison functionality.

3. VIEWING text file comparison report.

a) As XML: double-click on the file. System-assigned XML viewer/editor will open. By default, that would be Internet Explorer.

b) As a Web-page report.


DOWNLOAD, UNPACK and SAVE “showdiff.xsl” XSL parser script from this blog post according to the instructions provided along with the file link.

SAVE it on the same folder where you keep your XML files.

OPEN your XML in EDIT mode. (You can use WordPad or any other text editor).

ADD the following line as the FIRST LINE of the file:

AAxml-stylesheet type=”text/xsl” href=”showdiff.xsl”BB

Where AA should be <? And BB should be  ?> because it’s a special tag.

Double-click on the file. IE will display it as a web-page.

Note. As you can see now, you can easily automate the setup procedure as well by adding processing instruction so that your output XML files will contain call to the XSL parser script.

  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.