Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

XML::Twig compare Twigs

by Skeeve (Parson)
on Feb 13, 2004 at 22:04 UTC ( #328889=perlquestion: print w/replies, xml ) Need Help??

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

I'm using XML::Twig to parse small XML files read from a database. I want to copy the data from one database to another if it's not already there. If it's there I'd like to get information whether the data in the target DB is the same or different from the data in the source DB. With same I mean: It's the same structure and all the attributes are the same and have the same values. I want to ignore whitespace, comments and text. Don't post code how to do it. Please just tell me whether there are modules being able to do that.

Replies are listed 'Best First'.
Re: XML::Twig compare Twigs
by qq (Hermit) on Feb 14, 2004 at 00:01 UTC
      Almost but missed ;-)

      If I'm not completely wrong, Test::XML is not for comparing but for testing whether or not something is xml.

      XML::SemanticDiff could do it if my files were in the filesystem. But as I said: They are read from a database. I could save them in the file system but then I'd also need a module for random, unique filenames (Yes! I know there is one).

      Nevertheless: Thanks for your try.

      Regarding the (not-so-well) hidden allegation that I didn't search by myself. There is a reason behind it. You'll find the experts here. People with some experience. So why not hope one or the other has good recommendations for modules doing what I need. You can't recommend, as you stated yourself to have no experience.

      Let's hope someone with some more XML::Twig knowledge has an answer too.
        XML::SemanticDiff could do it if my files were in the filesystem. But as I said: They are read from a database.
        So, why is that a problem ? Doesn't matter, this is perl. Try either IO::Scalar or IO::String

        I believe this question has come up before, so I'd super search if I were you.

        update: upon closer examination, XML::SemanticDiff is built on XML::Parser, so no need for IO::Scalar or IO::String.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

        Sorry! I didn't mean it to be a jibe about not searching yourself, although I see it reads like that. I was actually trying to point out I wasn't providing a recommendation based on real use - the kind of thing you are right to expect from the monastery.

        I looked at all because I know I'll shortly be needing a similar task. Please post what solution you end up with

        BTW, on looking slightly further at XML::Test I see it uses XML::SematicDiff to do its comparisons. It is not testing if something is XML, but if two xml snippets are semantically equivalent. However its not really appropriate since a) its bulit as a Test module and b) its just using XML::SemanticDiff anyway.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://328889]
Approved by bart
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-11-29 01:34 GMT
Find Nodes?
    Voting Booth?