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

Parsing zipped xml data

by space_monk (Chaplain)
on Jan 08, 2013 at 10:13 UTC ( #1012212=perlquestion: print w/ replies, xml ) Need Help??
space_monk has asked for the wisdom of the Perl Monks concerning the following question:

So I wrote this little application at work using XML::Parser, and then my line manager said "that works great, but the files are huge and I'd be much happier if it took .gz files as input. Now as far as I know, XML::Parser is based on expat, and if I had chosen to write my app using XML::LibXML::Parser instead, which uses the C libxml2 library, it would have taken .gz files as input automagically.

What's the easiest way to get my XML::Parser based app to process .xml.gz files with the minimum of changes?

A Monk aims to give answers to those who have none, and to learn from those who know more.

Comment on Parsing zipped xml data
Re: Parsing zipped xml data
by Anonymous Monk on Jan 08, 2013 at 10:54 UTC
    gzcat, but you knew that already :)

      I probably did, but the grey cells that hold that information have been killed off by the influx of alcohol between XMas and New Year :-)

      Plus, I was interested to see various TMTOWTDI alternatives if there are any....

      A Monk aims to give answers to those who have none, and to learn from those who know more.
Re: Parsing zipped xml data
by Jenda (Abbot) on Jan 09, 2013 at 00:07 UTC

    The parse() method accepts an opened filehandle so something like

    use PerlIO::gzip; open my $IN, "<:gzip", "file.gz" or die $!; $parser->parse($IN); ...
    should work. (untested)

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-09-22 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (180 votes), past polls