Perl XML Parse

Parse a bit difficult XML.
To realize that, let’s use XML::Parser.

Sample Program

sub xmlparse {
   my $str = shift;
   my $handle_start = sub {
        my ($p, $elt, %atts) = @_;
   };
     
   my $handle_end = sub {
        my ($p, $elt) = @_;
   };
    
   my $handle_char = sub {
        my ($p, $str) = @_;
   }
   my $xml = new XML::Parser(Handlers => {
                                     Start   => $handle_start,
                                     End     => $handle_end,
                                     Char  => $handle_char});  
   $xml->parse($str);
}

In this case, I use no name sub module.
Start is to handle start element.
End is to handle end element
Char is to handle text between element

Ref

PerlMonks