Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Difficulty Mapping Data

by murugu (Curate)
on Sep 08, 2010 at 14:42 UTC ( #859336=note: print w/ replies, xml ) Need Help??


in reply to Difficulty Mapping Data

Thanks dasgar for sample input. I have used XML::Twig and xpath expression to do this.

use strict; use warnings; use XML::Twig; my $twiga=XML::Twig->new(); # create the twig for data1 $twiga->parsefile( 'data1.xml'); # build it my $twigb=XML::Twig->new(); # create the twig for data2 $twigb->parsefile( 'data2.xml'); # build it foreach my $t ($twiga->get_xpath('//host[@id]')) { my $att = $t->{'att'}->{'id'}; unless ($twigb->get_xpath("//host[\@id='$att']")) { print "$att is not found in data2.xml\n"; } foreach my $alias ($t->findnodes("host-alias")) { my $web = $alias->text; unless ($twigb->get_xpath("//host[\@id='$att']/host-alias[stri +ng()='$web']")) { print "$att with $web is not found in data2.xml\n" } } }

Regards,
Murugesan Kandasamy
use perl for(;;);


Comment on Re: Difficulty Mapping Data
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://859336]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-11-26 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls