#!/usr/bin/perl
use strict;
use XML::Parser::Expat;

my $parser = new XML::Parser::Expat;
$parser->setHandlers('Start' => \&start_handler,
		     'End'   => \&end_handler,
		     'Char'  => \&char_handler);

open(FOO, 'example1-xsd.xml') or die $!;

$parser->parse(*FOO);
close(FOO);

sub start_handler {
    my($p, $el, %atts) = @_;
    print "start_handler: '\$el' => $el\n";
    map { print "$_ => $atts{$_}\n" }  keys(%atts);
}

sub end_handler {
    my($p, $el) = @_;
    print "end_handler: '\$el' => $el";
}

sub char_handler {
    my($p, $str) = @_;
    print "char_handler: '\$str' => $str\n";
}

# ... Many other events
