Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, All Perl gurus! Does anyone know is there any smart "diff" modules to compare two big XML files and highlight the difference between them? The problem is that these XML files are just ONE long string and embedded with many <tag>value</tag> (space) <tag>value</tag> .... I think I can parse the file first to get tokens out(tag --> value), then do the comparsion. Thanks for any help. Dan

Replies are listed 'Best First'.
Re: Smart Diff - compare XML files
by Callum (Chaplain) on Nov 21, 2002 at 18:43 UTC
    XML::SemanticDiff should do what you're after, you may also wish to look at XML::DifferenceMarkup
Re: Smart Diff - compare XML files
by gjb (Vicar) on Nov 21, 2002 at 18:50 UTC

    IBM's AlphaWorks have a very nice XML diff tool. It works beautifully and has a good GUI. It has merge capabilities as well.

    Not Perl, but I hope it helps anyway, -gjb-

Re: Smart Diff - compare XML files
by mirod (Canon) on Nov 21, 2002 at 18:45 UTC

    Try XML::SemanticDiff.

    You could also pre-process the files to add \n between each elements and use a line-oriented diff, that might work, depending on your data.

Re: Smart Diff - compare XML files
by fruiture (Curate) on Nov 21, 2002 at 18:44 UTC

    I don't think there's such a module, but you're free to look for one.

    Anyway, I don't think it's too complicated: parse both XML Documents into a DOM and then recursively traverse the tree parallely. Whenever a difference occurs, pass the differing subtree to a function that "highlights" that subtree.

    --
    http://fruiture.de