http://www.perlmonks.org?node_id=1056285


in reply to XML Compare and exact differences need to be listed out

There are a number of tools (many non-Perl) that will do this for you. However, to help you, it would help to know:

For this kind of comparison I generally use TkDiff

or

Meld or just plain old diff at the command line(this is on *nix of course).

There are numerous tools for Windows as well. Winmerg being one of the free ones.

If you are looking for exclusively programmatic solutions, then knowing more about your environment is almost mandatory.

A quick google search for "diff tools written in perl" came back with Algorithm::Diff, which contrary to its name seems to do what you are describing."Algorithm::Diff - Compute `intelligent' differences between two files / lists"

Hope something in there is useful...


  • ...the majority is always wrong, and always the last to know about it...
  • ..by my will, and by will alone.. I set my mind in motion
  • Comment on Re: XML Compare and exact differences need to be listed out

Replies are listed 'Best First'.
Re^2: XML Compare and exact differences need to be listed out
by srikrishnan (Beadle) on Sep 30, 2013 at 09:03 UTC

    Hi,

    Thanks for your reply

    I am in Windows 7 and Activestate perl 5.10

    I am working in Arbortext Advanced print Publisher (3B2) software for Typesetting, this software supports perl, I want to include a perl script in this software for my requirement

    Thanks a lot

    srikrishnan

      Ok, that is a start. We know ActiveState and Win7.

      From your original post, your requirements are:

      • Output is to be a 3rd file containing the differences between original XML and corrected XML
      • Your changes may be as small as the spelling of a single word.
      What other differences would you want to capture?
      • Will a line by line compare work for you?
      • Do you expect larger changes, such as reordering of lines, replacement of lines/sections of the XML?
      • What do you expect the resultant file to look like? (line_number, orig_line, mod_line, change_txt...
      • I guess that leads to the question, what are you going to do with the output you generate? How will you use it?
      I see from some of your previous postings that you do know some Perl.

      You really do need to provide more info when you ask questions though.

      See How do I post a question effectively?.

      It will help others to help you more effectively. Best of luck ...


      • ...the majority is always wrong, and always the last to know about it...
      • ..by my will, and by will alone.. I set my mind in motion

        Hi

        Thanks for your further mail

        I just want line number, column number and the words

        If I get the above details, I will highlight the exact words in my PDF output through my Typesetting software

        I just want to highlight simple word deletions, insertions and modification details

        Thanks

        srikrishnan