#!/usr/bin/env/perl
use strict;
use warnings;
use XML::Parser::Expat;
use Data::Dumper qw(Dumper);
my $parser = XML::Parser::ExpatNB->new();
my $done;
$parser->setHandlers('Start' => \&sh,
'End' => \&eh,
'Char' => \&ch);
foreach my $snippet qw( < bro ke nx ml> con tent < /bro kenxm l> ) {
print "Waiting for an event...\n";
$parser->parse_more($snippet);
}
sub sh {
print "A start element: ", Dumper($_[1]), "\n";
}
sub eh {
print "An end element: ", Dumper($_[1]), "\n";
}
sub ch {
print "Some Data: ", Dumper($_[1]), "\n";
}
1;
|