use XML::Filter::Dispatcher qw( :all ); my $f = XML::Filter::Dispatcher->new( Rules => [ 'foo' => \&handle_foo_start_tag, '@bar' => \&handle_bar_attr, ## Send any elts and their contents to $handler 'snarf//self::node()' => $handler, ## Print the text of all elements 'description' => [ 'string()' => sub { push @out, xvalue } ], ], Vars => { "id" => [ string => "12a" ], }, );