Here is some code I wrote a while back that will do a recursive walk through a zip file that contains another zip and so on, to any depth. This code just prints the content, but the $unzip object at the line that says "Deal with the payload here" is just a filehandle, so if the xml parser accepts a filehandle it can be passed to it.

This code also has the advantage that it doesn't involve storing either the complete compressed or uncompressed data in memory. It streams all data as needed.

#!/usr/bin/perl use warnings; use strict; use IO::Uncompress::Unzip; sub walk { my $name = shift; my $fh = shift; my $indent = shift // 0 ; $indent += 2; my $unzip = new IO::Uncompress::Unzip $fh, or die "Cannot open zip\n" ; my $status; for ($status = 1; $status > 0; $status = $unzip->nextStream()) { my $name = $unzip->getHeaderInfo()->{Name}; warn " " x $indent . "Processing member $name\n" ; if ($name =~ /.zip$/) { walk($name, $unzip, $indent); } else { # Deal with the payload here my $buff; while (($status = $unzip->read($buff)) > 0) { # Do something here print "$buff\n"; } } last if $status < 0; } die "Error processing $name: $!\n" if $status < 0 ; } my $file = shift; my $fh ; open $fh, "<$file" ; warn "Processing zip file $file\n"; walk($file, $fh);

In reply to Re: Double zipped files by pmqs
in thread Double zipped files by guzziee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.