Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: parse XML huge file using cpan modules

by choroba (Bishop)
on Jul 28, 2019 at 19:48 UTC ( #11103542=note: print w/replies, xml ) Need Help??


in reply to parse XML huge file using cpan modules

For really large files, you can use XML::LibXML::Reader.
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use XML::LibXML::Reader; my $r = 'XML::LibXML::Reader'->new(location => shift); say 'time|resourceGroup|LCONNFAIL|LLOSTCONN|LIDLETIMEOUT|SIPADDR|SIPPO +RT'; my %dispatch = ( statRecord => sub { print $r->getAttribute('time'), '|'; }, resourceGroup => sub { print $r->getAttribute('name'); }, name => sub { my $name = $r->readInnerXml; return unless $name =~ /^(?:LCONNFAIL|LLOSTCONN|LIDLETIMEOUT|SIPADDR|SIPPORT)$ +/; $r->nextSiblingElement('value'); print '|', $r->readInnerXml; print "\n" if $name eq 'SIPPORT'; } ); while ($r->read) { next unless $r->nodeType == 1; my $action = $dispatch{ $r->name }; $action->() if $action; }

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: parse XML huge file using cpan modules
by nicopelle (Acolyte) on Jul 29, 2019 at 11:29 UTC
    @choroba , your code works flawless too ! Thanks for your support and not least for your teachings.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11103542]
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: (10)
As of 2019-10-22 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?