Masayoshi Sekimura

NAME

XML::SAX::SimpleDispatcher - SAX handler to dispatch subroutines based on XPath like simple path and name of children tags under that node.

SYNOPSIS

    use XML::SAX::SimpleDispatcher;
    use XML::SAX::ParserFactory;
    my $stash;
    my $handler = XML::SAX::SimpleDispatcher->new(
        process => {
          '/Books/Book' => [ sub { push @$stash, $_[0]}, ['Title'] ],
        }
    );
    my $parser = XML::SAX::ParserFactory->parser(Handler => $handler);
    $parser->parse_string('<Books><Book><Title>Learning Perl</Title></Book></Books>');
    ## And then, $stash has a list of context inside of 'Title' tag

DESCRIPTION

XML::SAX::SimpleDispatcher dispatches subroutine calls based on a XPath like path. This can be handy tweaking children nodes data while parsing data by SAX parser.

METHODS

new
    my $handler = XML::SAX::SimpleDispatcher->new(
        process => {
          '/MyShelf/Book'  => [ sub { push @$stash, $_[0]}, ['Title'] ],
          '/MyShelf/Movie' => [ sub { push @$stash, $_[0]}, ['Title'] ],
        }
    );

Creates a new XML::SAX::SimpleDispatcher instance.

with process option, you can put a hash reference which has several paths as keys and array references of a list of subroutine reference and an array reference.

Well, it might not look simple but you can dispatch *characters* to each subroutine.

AUTHOR

Masayoshi Sekimura <sekimura@cpan.org>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO