in reply to Parsing XML: Not an Array/Hash Reference Error

If I use XML::Twig, this code works if I have 1 'article' element, or 2 or 3 (I didn't try more than 3, but I believe it will work for 100). The output below shows the case with 2 articles (which is your XML example):
use strict; use warnings; use XML::Twig; my $file_in = shift; my $twig= new XML::Twig( twig_handlers => { reference => \&reference } ); $twig->parsefile($file_in); exit; sub reference { my ($twig, $refer) = @_; print $refer->text(), "\n"; } __END__ distdoc:archive/ArchiveDoc::Article/MTPW000020090731e57v004mr distdoc:archive/ArchiveDoc::Article/MTPW000020090731e57v004mr

Replies are listed 'Best First'.
Re^2: Parsing XML: Not an Array/Hash Reference Error
by leighgable (Acolyte) on Aug 15, 2009 at 13:11 UTC
    Hello Toolic,

    I am going through the XML::Twig documentation now. I think it's exactly what I need for my project.

    Your program is my first look at the parameter array. It's really cool what you did!

    Thanks, Leigh