Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Seaching for text in string and comparing to xml, if not found print text

by choroba (Canon)
on Feb 14, 2013 at 10:09 UTC ( #1018711=note: print w/ replies, xml ) Need Help??


in reply to Seaching for text in string and comparing to xml, if not found print text

Maybe a bit late, but one has to sleep sometimes. Here is the Proper Way™, i.e. using a pull-parser to process the huge XML:

#!/usr/bin/perl use warnings; use strict; use XML::LibXML::Reader; open my $TXT, '<', '1.txt' or die $!; my %ids; while (<$TXT>) { undef $ids{ (split /,/)[5] }; } close $TXT; my $xml = XML::LibXML::Reader->new( location => '1.xml' ) or die "Cannot open xml\n"; while ($xml->nextElement('ALERT_ID')) { $xml->read; # Go to the text value. my $id = $xml->value; if (exists $ids{$id}) { delete $ids{$id}; } else { warn "Not found in csv: $id\n"; } } print "$_\n" for keys %ids;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Seaching for text in string and comparing to xml, if not found print text
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2015-07-02 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (34 votes), past polls