Skip to Main Content Skip to Search
Product Documentation

How to Compare XML Files

Introduction

You can use MATLAB Report Generator software to compare a pair of XML text files.

The XML comparison tool processes the results into a report that you can use to explore the file differences.

You can access the XML comparison tool from:

The XML comparison tool compares the files using the "Chawathe" algorithm, as described in this paper:

Change Detection in Hierarchically Structured Information, Sudarshan Chawathe, Anand Rajaraman, and Jennifer Widom; SIGMOD Conference, Montreal, Canada, June 1996, pp. 493-504.

This conference paper is based upon work published in 1995: see http://dbpubs.stanford.edu:8090/pub/1995-45.

XML comparison reports display in the Comparison Tool. For more information about the Comparison Tool, see Comparing Files and Folders in the MATLAB Desktop Tools and Development Environment documentation.

The XML comparison report shows a hierarchical view of the portions of the two XML files that differ. The report does not show sections of the files that are identical.

If the files are identical you see a message reporting there are no differences.

Change detection in the Chawathe analysis is based on a scoring algorithm. Items match if their Chawathe score is above a threshold. The MATLAB Report Generator implementation of Chawathe's algorithm uses a comparison pattern that defines the thresholds. For more information, see How The Matching Algorithm Works.

Selecting Files to Compare

From the Current Folder Browser

To compare two files from the Current Folder browser:

If the selected files are XML files, the XML comparison tool performs a Chawathe analysis on the files and displays a report in the Comparison Tool.

The file you right-click to launch the XML comparison tool displays on the right side of the report.

For more information about comparisons of other file types with the Comparison Tool, such as text, MAT or binary, see Comparing Files and Folders in the MATLAB Desktop Tools and Development Environment documentation.

From the Comparison Tool

To compare files using the Comparison Tool, launch the tool from the MATLAB Desktop menu, and select File > New Comparison. In the dialog box select files to compare.

If the files you select to compare are XML files and you select an XML comparison, the XML comparison tool performs a Chawathe analysis of the XML files, and generates an report.

From the Command Line

To compare XML files from the command line, enter

visdiff(filename1, filename2)

where filename1 and filename1 are XML files. This XML comparison functionality is an extension to the MATLAB visdiff function.

Changing Comparison Type

If you specify two XML files to compare using either the Current Folder Browser or the visdiff function, then the Comparison Tool automatically performs the default comparison type, XML text comparison.

To change comparison type, either create a new comparison from the Comparison Tool, or use the Compare Against option from the Current Folder browser. You can change comparison type in the Select Files or Folders for Comparison dialog box. If you want the MATLAB text differences report for XML files, change the comparison type to Text comparison in the dialog before clicking Compare.

XML Comparison Demos

For an example with instructions, see the mlxml_testplan demo.

See Also

For explanations on how to use and understand the report and the XML comparison functionality, refer to:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS