#!/usr/bin/perl -w # twigtest.pl use strict; use XML::Twig; my $t = new XML::Twig( TwigHandlers => { 'download' => \&tag_download, '_default_' => \&tag__default, } ); if (!($t->safe_parsefile('test.xml'))) { warn("Error: Test XML had processing errors: $@\n"); } # Handles the tag. sub tag_download { my ($t,$elt) = @_; print("Found a !\n"); $t->purge(); } # Handles any unrecognized tag. sub tag__default { my ($t,$elt) = @_; print("Unrecognized tag: <".$elt->gi().">!\n"); $t->purge(); } #### #### Found a !