XMLDiff 1
This is the first release of xmldiff, now bundled with libxmldiff. You should really use the new version. The one below is only kept for historical purpose.
Download
Xerces Version (xmldiff 1.x)
Download the source (C++, VS & GCC, need Xerces-C)
Download the win32 binaries
Usefull other software
Download the XML Diff Tree View program (Win32 binary only)
Download the GUI launcher binary to have a basic GUI support
What ?
XMLDiff aims at providing efficient diff on XML files.
Features are :
- Detection of modified items, added items, removed items
- Not sensitive to item position changes (based on a id).
- Designed to support large XML files (about 50 Mo). For larger files, treat these files with XML Pre Diff Tool (see below) would be a good idea.
- Simple to use
How expansive is it ?
These programs are released under the GPL license. It allows you to use the program at no charge, and freely adapt the provided source code to your needs.
How to use ?
The program is splitted in three parts :
- xmldiff : is the main program, in command line.
- launcher / xmldiff.xml / xmldiff.bat : is a simple GUI frontend.
- XMLDiffTreeView : is a simple XML Tree navigator, which uses the diff:status calculated by xmldiff, and which is also optimized for large files.
XMLDiff
XMLDiff diffs two files, and output a file with exactly the same structure (unlike other xml diffing utilities), and containing an extra diff:status attribute.
The meaning of this diff:status argument is :
- added : the element has been added.
- removed : the element has been removed.
-
modified : either an argument or the text has been modified, the values will be outputted with the ‘ ’ separator : “before after”. - below : the element itself was not modified, but a child item was.
<span style="color: #008080;"><test </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"below"</span> <span style="color: #2e8b57;"><b>xmlns</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>diff</b></span>=<span style="color: #ff00ff;">"http://www.via.ecp.fr/~remi/soft/xml/xmldiff"</span><span style="color: #008080;">></span>
<span style="color: #008080;"><file </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"added"</span> <span style="color: #2e8b57;"><b>id</b></span>=<span style="color: #ff00ff;">"2"</span><span style="color: #008080;">/></span>
<span style="color: #008080;"><att </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"modified"</span> <span style="color: #2e8b57;"><b>id</b></span>=<span style="color: #ff00ff;">"1"</span> <span style="color: #2e8b57;"><b>old</b></span>=<span style="color: #ff00ff;">"tata|toto"</span> <span style="color: #2e8b57;"><b>removed</b></span>=<span style="color: #ff00ff;">"|toto"</span><span style="color: #008080;">/></span>
<span style="color: #008080;"><file </span><span style="color: #2e8b57;"><b>att</b></span>=<span style="color: #ff00ff;">"tot|"</span> <span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"modified"</span> <span style="color: #2e8b57;"><b>id</b></span>=<span style="color: #ff00ff;">"12"</span><span style="color: #008080;">></span>
<span style="color: #008080;"><name </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"modified"</span><span style="color: #008080;">></span>toto.dat|toto.cfg<span style="color: #008080;"></name></span>
<span style="color: #0000ff;"><!</span><span style="color: #0000ff;">-- Test --</span><span style="color: #0000ff;">></span>C'est toto !
<span style="color: #008080;"></file></span>
<span style="color: #008080;"><file </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"added"</span> <span style="color: #2e8b57;"><b>id</b></span>=<span style="color: #ff00ff;">"24"</span><span style="color: #008080;">/></span>
<span style="color: #008080;"><tulipe </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"modified"</span> <span style="color: #2e8b57;"><b>id</b></span>=<span style="color: #ff00ff;">"42"</span><span style="color: #008080;">></span>Tulipe|Tulipe 2<span style="color: #008080;"></tulipe></span>
<span style="color: #008080;"><toto </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"added"</span><span style="color: #008080;">></span>Titi !<span style="color: #008080;"></toto></span>
<span style="color: #008080;"><section1 </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"below"</span><span style="color: #008080;">></span>
<span style="color: #008080;"><section2 </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"below"</span><span style="color: #008080;">></span>
<span style="color: #008080;"><section3></span>Test<span style="color: #008080;"></section3></span>
<span style="color: #008080;"><section3 </span><span style="color: #2e8b57;"><b>diff</b></span><span style="color: #0000ff;">:</span><span style="color: #2e8b57;"><b>status</b></span>=<span style="color: #ff00ff;">"removed"</span><span style="color: #008080;">></span>Test<span style="color: #008080;"></section3></span>
<span style="color: #008080;"></section2></span>
<span style="color: #008080;"></section1></span>
<span style="color: #008080;"></test></span>
Screenshot of the UI :
Options are :
xmldiff - diff two XML files. (c) 2004 - Rémi Peyronnet
Syntax : xmldiff [options] [file before.xml] [file after.xml]
Options :
--output output.xml : Output to the provided file name
--sep | : Use this as the separator
--before-values yes : Add before values in attributes or text nodes
--pretty-print yes : Output using pretty print writer
--ids '@id,@value' : Use these item to identify a node
--clean-text yes : Remove all blank spaces
--tag-childs yes : Tag Added or Removed childs
- Avant / Apres / Sortie : Before / After / Output files.
- –ids / “Ids” : items to be taken for id. Id is used to sort items, nd not be sensitive to the order of elements. Attributes should be preceded by ‘@’. Nodes should be used carefully, as this as significant impacts over performance.
-
–before-value no / “Ne pas indiquer les valeurs précédentes” : don’t output “before after” values. The last value available is used. - –clean-text no / “Ne pas supprimer les blancs” : blank spaces, carriage returns,… are removed. Unchecking this option will drastically improve the performances, but will show false differences (ex : when an element is added, a blank text element is often added too…)
- –tag-childs no / “Ne pas marquer les fils” : Checking this option will prevent xmldiff to tag child of added/removed nodes with the same status.
- –pretty-print no / “Ne pas formater le xml produit” : Checking this option will prevent xmldiff to pretty print the output. Use this with –clean-text no / “Ne pas supprimer les blancs”.
This diff:status attribute is very easy to handle in XSL Stylesheet, and you can make the XSL for the better display of your xml document. You can also use the generic XMLDiffTreeNav below :
XMLDiffTreeNav
This tool provides an easy browsing of xml diff files : icons are representing the diff status : ‘+’ means ‘added’, ‘-‘ means ‘removed’, ‘?’ means that there is a modification in the child items, and a yellow block show an element with a modification. In the modified item, the values before and after are provided : “before | after”. |
A button in the toolbar can be used to show only modified items : unchanged items will be hidden. This is very usefull for files where there are only few differences.
Screenshot of XMLDiffTreeView :