[VPM] Comparing XML File
Peter Scott
Peter at PSDT.com
Wed Dec 8 14:50:27 CST 2004
At 12:36 PM 12/8/2004, abez wrote:
>Parse the XML into a tree composed of arrays (because you have more than
>one subelement of the same type). Since I can't care less about XML I'll
>discuss the algorithm.
>
>You want to see if a is in b and b is in a (therefore they are equal).
>Foreach element in a that element should exist in b. You have a problem
>that references will not be equal.
>
>This is actually a graph isomorphism problem on a tree. Graph
>Isomorphisms tests are generally believed to be NP (Non-Polynomial Time
>(aka they take a LONG TIME to compute)). I would've rather written this
>in ML :(
[snip]
>On Wed, 8 Dec 2004, Philip Yuson wrote:
>
> > Anyone knows of a script that compares 2 xml files
> > The tags will be in a different order.
Maybe I'm missing something, but this sounds more like a problem of
converting the input to a canonical form with the tags in a sorted
order and stringwise comparing serializations. I don't feel like
plowing through the massive XML corpus on CPAN right now but there's
got to be something there that would make that reasonably
easy. There's XML::Canonical, but I don't know about the tag sorting.
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
*** New! *** http://www.perlmedic.com/
More information about the Victoria-pm
mailing list