Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

XML compare with a key

by PiyaPerl (Acolyte)
on Apr 02, 2019 at 11:51 UTC ( [id://1232000]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all, I need an input that if I have 2 XML files which I need to compare like below :
<xml top> <xml body> <tag1>jdjdjdjd</tag1> <tag2>dkdkkd</tag2> </xml body> </xmltop> and second file like <xml top> <xml body> <tag2>jdjdjdjd</tag2> <tag1>ghghgh</tag1> </xml body> </xmltop>
So basically the order is different but i want o simply set a key and compare like for like.

Replies are listed 'Best First'.
Re: XML compare with a key
by hdb (Monsignor) on Apr 02, 2019 at 12:36 UTC

    As one option, you could use XML::Simple to translate both your xml strings into hash references and then walk through both of them to spot the differences. You could also use a module that does it for you, for example XML::Diff or XML::SemanticDiff.

        I am getting tired by being pointed to this comment each and every time. For such simple stuff the module is still useful.

        And anyways, the OP will reply that (s)he does not want to install any module, see earlier questions... Re^4: XML file difference highlights

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-18 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found