Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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.

Replies are listed 'Best First'.
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)

    Enoch was right!
    Enjoy the last years of Rome.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012212]
Approved by vinoth.ree
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2018-06-25 16:31 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (127 votes). Check out past polls.