in reply to Re^3: Open a zip file content question!
in thread Open a zip file content question!

Almost, but still giving an error:
my $zipfile = "test.zip"; my $zip = Archive::Zip->new( $zipfile ) || die; my @xml = $zip->membersMatching( '.*\.XML' ); my $xmlfile = XML::XPath->new(ioref => $xml[0]->readFileHandle ); #error: not well-formed (invalid token) at line 1, column 24, byte 24: Archive::Zip::MemberRead=HASH(0x2063604) =======================^

Replies are listed 'Best First'.
Re^5: Open a zip file content question!
by Anonymous Monk on Mar 04, 2011 at 14:06 UTC
    Almost, but still giving an error:

    Keep going?

      The problem still remains, that's what I meant. Here is the code I am tying with your recommendations, any suggestions?
      #!/usr/bin/perl use strict; use warnings; use Archive::Zip; use Archive::Zip::MemberRead; my @numberstocheck = qw(112334 999888 222333 999888 0008877 003344 122 +2334 00009 004443 999888); my $zipfile = "test.zip"; my $zip = Archive::Zip->new( $zipfile ) || die; my @xml = $zip->membersMatching( '.*\.XML' ); #my $xmlfile = XML::XPath->new(ioref => @xml); my $xmlfile = XML::XPath->new(ioerf => $xml[0]->readFileHandle ); foreach my $row ($xmlfile->findnodes('/alllist')) { my $nodeset = $row->find('phnumbers'); foreach my $node ( $nodeset->get_nodelist ) { my $numbers = $node->find( 'numbers')->string_value; print "\n 19 - $numbers \n"; foreach (@numberstocheck) { if (/^($numbers)/g) { print "$numbers - ".$_."\n"; } } } }
      That's the frustrating error:
      not well-formed (invalid token) at line 1, column 24, byte 24: Archive::Zip::MemberRead=HASH(0x2061dfc) =======================^ at C:/Perl/lib/XML/Parser.pm line 187
        Let me just correct these lines, but it still doesn't work: This line should be there just a typo here:
        #this line should be on top use XML::XPath; #and this line has been corrected: #my $xmlfile = XML::XPath->new(ioerf => $xml[0]->readFileHandle ); my $xmlfile = XML::XPath->new(ioref => $xml[0]->readFileHandle );
        Error:
        not well-formed (invalid token) at line 1, column 24, byte 24: Archive::Zip::MemberRead=HASH(0x2062784) =======================^ at C:/Perl/lib/XML/Parser.pm line 187
        Thanks for looking!