Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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: (8)
As of 2015-07-06 08:39 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 (70 votes), past polls