I've looked at the answers to this question, and unfortunately none of them has helped me so far.

Not to beat about the bush, the second edition of C# in Depth is now in copy edit. I want to be able to see what the copy editor's done really easily, so I can reject or accept his changes.

We're using a modified form of docbook, but I'm happy enough looking at the raw XML source. All fine so far - except that when the copy editor makes a change, that can change the line wrapping. So something that used to read:

<para>Foo bar baz
 second line</para>

now reads

<para>Foo bar grontle
 baz second line</para>

Now the real change here is the insertion of "grontle". I don't care that "baz" has moved from the first line to the second line, but all the diff tools I've seen do.

I realise that one option would be to reformat the whole document (or possibly just whole paragraphs) into single lines... but that's then really hard to read, because diff tools don't wrap when they're displaying.

I'm sure I can manage with the tools I've got, but if anyone knows of anything better, I'd be really glad to hear about it. I suspect my publishers would too.

(I've included the Windows tag here because I'd really need it to be available on Windows. I'd like to hear about any non-Windows software too, but only in case I could help to build it on Windows.


Looks like SourceGear DiffMerge will give you this, with its ruleset support for XML (and lots of other languages). I'm not sure if it will fix all your problems, because the example is of course a simplification of the actual program. I tried slightly more complex changes, and those seem to work fine too.

See the sample below for the diff you described

simple diff

  • 1
    I've just had a quick look with the real files, and it looks like it does the job perfectly. Thank you so much! – Jon Skeet Apr 9 '10 at 5:31

My solution is with beyond compare. ( a much more powerfull tool )

So we start by seeing the problem.

enter image description here

BC has a special XML parsing role : ( it has already XML role , but not with pre-analysis - which is Sorted and Tidied)

enter image description here

so we go to http://www.scootersoftware.com/download.php?zz=kb_moreformats_alt

enter image description here

and now -

enter image description here

hope you'll use it for next edition of C# in depth

p.s. if the text in pictures is too small, just click on the picture to load the original ones.


I'm the author of an XML diff tool (commercial software) that should do the job (and some more features). There is a test version (which is limited to Xml files of 100 KBs max.) for download here:


A short introduction is also available here:



I had this same problem at a company not too long ago. They wanted to find a true "XML differ", and there don't appear to be any complete solutions out there.

The easiest solution is to run a pretty-print script on the XML first to normalize the line-endings and spacing, and then run the diff tool of choice (WinMerge is nice for windows). This drops a lot of the flotsam that most difftools will throw at you from XML, and is really easy to build a script around.

  • The trouble is that the XML already is pretty-printed, effectively - it's the insertions and deletions that change where lines are wrapped. I wonder whether I need something to reformat one file based on the words that occur at the ends of lines in another :( – Jon Skeet Apr 8 '10 at 20:47

SD Smart Differencer compares documents based on structure as opposed to actual layout.

There's an XML Smart Differencer. For XML, that means matching order of tags and content. It should note that the text string in the specific fragment you indicated was different. (It presently doesn't understand the XML notion of text in which whitespace is normalized vs. significant, but I suspect that won't hurt you a lot).


@Jon Skeet: You mentioned in your question that diff tools don't wrap when they display.
vimdiff (also available on windows via gvim) allows you to wrap the displayed xml files with :window set wrap. Reference link.
Also you can run :diffupdate to refresh the diffs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.