Are there any free Xml Diff/Merge tools available? [closed]
Asked Answered
S

11

110

I have several config files in my .net applications which I would like to merge application settings elements etc.

I was about to begin doing it manually as I usually do, however thought there must be an XML diff GUI tool available somewhere.

The tool would be able to go to the element level to compare and display the differences etc.

However Google gave no substantive free tool results and no hints for anything of value.

Is such a tool available? That is very useful? For free?

Thanks in advance. :)

Edit:

Here is a bit of clarification of the functionality that would turn my error-prone, tedious manual job into a 1-minute simpler task (and potential to automate):

In KDiff3, you can do a diff/merge of entire directories. There is a hierarchical diff which is very accurate, user-friendly and clear. I was interested in finding a similar solution, however instead of directory hierarchy, an XML element hierarchy.

If there is no such open source software, I am considering creating one on CodePlex to provide this functionality.

Swiss answered 9/12, 2009 at 1:28 Comment(3)
I recently came across this website which does some xml and json comparison online. jsoftwarelabs.com/jslutils/xml-comparisonDemott
jsoftwarelabs.com/jslutils/xml-comparisonDemott
@Demott that one works just great. Had to compare two files with lists of different order and could easily verify if all elements where present even when in random order.Kindhearted
L
10

KDiff3 is not XML specific, but it is free. It does a nice job of comparing and merging text files.

Laciniate answered 9/12, 2009 at 1:31 Comment(13)
I agree I am using KDiff3 at the moment, however a tool specifically for XML that could go down to the element level would be terrific.Swiss
If a child of a node has changed, then surely the node itself has materially changed. I don't think I quite follow what a tool specific to XML would do in such a case that would be different from diff (pardon the pun).Peary
I was thinking from this perspective: the way KDiff does a hierarchical diff of directories, a hierarchical diff of elements could also work. So if an element has changed, then I agree, the parent elements should also be flagged as having changed.Swiss
Ah, I get it now, many thanks. You're looking for a diff tool that can report a change in a line of text that actually hasn't itself changed, but for which a "nested" line of text has changed. Gotcha. That would be very useful. Apologies for not cottoning-on earlier.Peary
everyone realizes that in xml the child nodes are not guaranteed to be in any specific order, so any "tool" that reported that something was not in the same order from one file to the next really won't be a real xml compliant toolGeneralissimo
Yeah that makes this more complicated, however there may be ways to help the diff tool, eg. attributes may indicate which elements are the same in the two documents etc. Good point though :)Swiss
Even assuming we could control the order by ordering alphabetically first would eliminate any issues with XML element order.Swiss
If the order changes, then the elements are different. Depending on the semantics of the XML document in question, the order may, or may not, be significant. E.g. in XHTML obviously the order matters.Cachet
The point is that a regular diff tool works line based. There are specific diff tools for e.g. CSV files that understand the format it is diffing. The better that understanding, the more effective the diffing can happen. A good XML diff tool would be able to parse the XML, use a schema to determine constraints such as whether order matters for example, and then use that knowledge to give a far more effective diff / merge experience.Hoeg
@JarrodRoberson I don't get your argument. A XML diff tool is used to visualize changes in the file, it's not used to validate it in any way. Order can obviously be very significant for many consumers of XML.Underproduction
@Underproduction - order is not guaranteed by the XML specification and any specific parser implementation could change from version to version so the order in the text file is irrelevant to the order in the parsed result.Generalissimo
@JarrodRoberson You are being unnecessary general. A specific parser could very well guarantee order. And XML schemas are perfectly fine with defining order. Your argument that a xml-specialiced diff tool that shows differing order wouldn't be xml compliant is just strange. Again, it's a diff tool, not a validation tool. The purpose of a diff tool is to show changes between versions, of course it should show when you are moving things around. And the order might very well be the difference of the file being valid or not accordingly to a specific XML scheme.Underproduction
elements and attributes in different orders is different, there is no arguing that saying that they can be in different orders and be the same is ignoring that fact.Generalissimo
S
34

Have a look at File comparison tools, from which I am using WinMerge. It has an ability to compare XML documents (you may wish to enable DisplayXMLFiles prefilter for v2.14.0 or PrettifyXML for v2.16.x).

DisplayXMLFiles.dll - This plugin pretty-prints XML files nicely by inserting tabs and line breaks. This is useful for XML files that do not have line returns in convenient locations.

Note for v2.16.x

The plugin PrettifyXML is supplied with the software package. It can be activated as following:

  • Make sure that Plugins → Plugin Settings → Enable plugins is enabled.
  • Then use either File → Recompare As → Prettify XML or Plugins → Scripts → Prettify XML

For those who wish to play with deprecated DisplayXMLFiles, he needs to download e.g. winmerge-2.16.14-full-src.7z and copy Plugins\dlls\X64\DisplayXMLFiles.dll to WinMerge\MergePlugins\.

WinMerge in action

See also my feature comparison table.

Sensitivity answered 23/8, 2011 at 13:29 Comment(6)
+1 Winmerge version 2.12.4.0; Menu "Plugin" -> "List" -> check "Enable Plugins"; Menu "Plugin" -> check "Automatic unpacking". Tested with XML file with file name with extension .xml and it seems to work.Demiurge
It doesn't deal well with attributes being in different orders, so it's usefulness might be limited, depending on your situation.Buford
Use this transform on any XML files first to sort elements and attributes: https://mcmap.net/q/196502/-xslt-to-sort-nodes-by-nameJuggler
Looks like the plugin is no longer available.Allineallis
I'm not sure why it's not in the installer, but I was able to get it from their src repo on bitbucket / source code (sourceforge DL) : bitbucket.org/winmerge/winmerge/src/…Cuirassier
There is an item in the menu: "File > Recompare As > XML" Version 2.16.8.0Evocator
D
21

I wrote and released a Windows application that specifically solves the problem of comparing and merging XML files.

Project: Merge can perform two and three way comparisons and merges of any XML file (where two of the files are considered to be independent revisions of a common base file). You can instruct it to identify elements within the input files by attribute values, or the content of child elements, among other things.

It is fully controllable via the command line and can also generate text reports containing the differences between the files.

Project: Merge merging three XML files

Dustindustman answered 27/2, 2011 at 20:45 Comment(4)
I've tried Project::Merge and unfortunately it was not able to cope with my task. I have HTML text in paras (<p>) which is added formatting (like <i>, <em>). So Project::Merge shows that complete para was changed, it does not do in-depth word analysis.Sensitivity
Yes, I'm sorry to say that XHTML (it will never do legacy HTML) support is pretty limited in that respect, as is text differencing within XML blocks in general. Most work so far have been focused on configuration-style XML files where free form character data is limited in its extent and usage. Hopefully I'll improve Project: Merge in this area in a future release.Dustindustman
-1, The OP asked about free software. Project Merge is trialware and also hasnt been updated in 3 years.Romanesque
Project:Merge has now been replaced by Oso XML Merge: osocorporation.com/xmlmerge/index.phpThersathersites
G
14

There are a few Java-based XML diff and merge tools listed here:

Open Source XML Diff written in Java

Added links:

Godding answered 9/12, 2009 at 1:35 Comment(3)
I am having trouble finding any links to the software in the link you mentioned.Swiss
Yeah, me too! Might need to Google around a bit...Godding
Not useful without listing the tools' XML-specific capabilities. From what I can see, these are all regular diff tools without element-level comparison.Arvind
L
10

KDiff3 is not XML specific, but it is free. It does a nice job of comparing and merging text files.

Laciniate answered 9/12, 2009 at 1:31 Comment(13)
I agree I am using KDiff3 at the moment, however a tool specifically for XML that could go down to the element level would be terrific.Swiss
If a child of a node has changed, then surely the node itself has materially changed. I don't think I quite follow what a tool specific to XML would do in such a case that would be different from diff (pardon the pun).Peary
I was thinking from this perspective: the way KDiff does a hierarchical diff of directories, a hierarchical diff of elements could also work. So if an element has changed, then I agree, the parent elements should also be flagged as having changed.Swiss
Ah, I get it now, many thanks. You're looking for a diff tool that can report a change in a line of text that actually hasn't itself changed, but for which a "nested" line of text has changed. Gotcha. That would be very useful. Apologies for not cottoning-on earlier.Peary
everyone realizes that in xml the child nodes are not guaranteed to be in any specific order, so any "tool" that reported that something was not in the same order from one file to the next really won't be a real xml compliant toolGeneralissimo
Yeah that makes this more complicated, however there may be ways to help the diff tool, eg. attributes may indicate which elements are the same in the two documents etc. Good point though :)Swiss
Even assuming we could control the order by ordering alphabetically first would eliminate any issues with XML element order.Swiss
If the order changes, then the elements are different. Depending on the semantics of the XML document in question, the order may, or may not, be significant. E.g. in XHTML obviously the order matters.Cachet
The point is that a regular diff tool works line based. There are specific diff tools for e.g. CSV files that understand the format it is diffing. The better that understanding, the more effective the diffing can happen. A good XML diff tool would be able to parse the XML, use a schema to determine constraints such as whether order matters for example, and then use that knowledge to give a far more effective diff / merge experience.Hoeg
@JarrodRoberson I don't get your argument. A XML diff tool is used to visualize changes in the file, it's not used to validate it in any way. Order can obviously be very significant for many consumers of XML.Underproduction
@Underproduction - order is not guaranteed by the XML specification and any specific parser implementation could change from version to version so the order in the text file is irrelevant to the order in the parsed result.Generalissimo
@JarrodRoberson You are being unnecessary general. A specific parser could very well guarantee order. And XML schemas are perfectly fine with defining order. Your argument that a xml-specialiced diff tool that shows differing order wouldn't be xml compliant is just strange. Again, it's a diff tool, not a validation tool. The purpose of a diff tool is to show changes between versions, of course it should show when you are moving things around. And the order might very well be the difference of the file being valid or not accordingly to a specific XML scheme.Underproduction
elements and attributes in different orders is different, there is no arguing that saying that they can be in different orders and be the same is ignoring that fact.Generalissimo
A
4

Pretty Diff tool was created with XML in mind. Just ensure you click the option for "markup".

http://prettydiff.com/

Acrodont answered 12/3, 2011 at 12:16 Comment(2)
But that is online tool, right? How can I apply changes from left to right or merge?Sensitivity
You also need to change the options for sorting, otherwise it flags XML elements as changed when all they did was move (order doesn't matter in XML so this shouldn't appear as a change). It still doesn't sort nested sections based on their content though, so you will still see additions and removals of large XML blocks when all that happened was the elements changed order, so it's not possible to get a fine-grained diff.Olympe
P
3

While this is not a GUI tool, my quick tests indicated that diffxml has some promise. The author appears to have thought about the complexities of representing diffs for nested elements in a standardized way (his DUL - Delta Update Language specification).

Installing and running his tools, I can say that the raw text output is quite clear and concise. It doesn't offer the same degree of immediate apprehension as a GUI tool, but given that the output is standardized as DUL, perhaps you would be able to take that and build a tool to generate a visual representation. I'd certainly love to see one.

The author's "links" section does reference a few other XML differencing tools, but as you mentioned in your post, they're all proprietary.

Peary answered 9/12, 2009 at 2:9 Comment(1)
My experience is that: It can't handle reordering of elements at all, which is something that'd be expected in an XML tool (as an option, because sometimes order is important), and instead of minimal diffs it shows entire changed elements. Basically the diff file is just a whole new XML file if there are major formatting changes without big semantic changes.Sinistrocular
M
2

A7Soft provide XML comparison tools freeware and shareware:

http://www.a7soft.com

Mayfair answered 28/3, 2012 at 13:8 Comment(0)
A
1

I use TortoiseMerge, which is included in TortoiseSVN program

And we have talked about File Diff tools in this thread, not dedicated to XML though

https://stackoverflow.com/questions/1830962/file-differencing-software-on-windows

Auditor answered 9/12, 2009 at 1:43 Comment(1)
Thanks S.Mark, as I mentioned to epotter, I already use KDiff3 for general file diffs, however I would really prefer an XML specific diff utility if it is available (if not, I will start up an open-source one :) )Swiss
N
0

Altova's DiffDog has free 30-day trial and should do what you're looking for:

http://www.altova.com/diffdog/diff-merge-tool.html

Nardi answered 9/12, 2009 at 19:0 Comment(1)
did you read the question propertly? it says free!Ratty
F
0

This is a diff engine for java developers, but it comes with a demo interface - you might be able to use it: https://community.emc.com/docs/DOC-5042

Fabrianne answered 15/12, 2009 at 12:47 Comment(0)
O
0

I recommend you to use CodeCompare tool. It supports native highlighting of XML-data and it can be a good solution for your task.

Oriole answered 7/6, 2010 at 7:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.