use strict;
use XML::Twig;
my $t = XML::Twig->new(
twig_handlers => {table => \&handler},
pretty_print => 'indented',
);
$t->parse(\*DATA);
sub handler {
my($t,$table) = @_;
$table->flush
if $table->att('border') == 0
and $table->att('align') eq 'center'
;
}
__DATA__
XML::Twig table extract test
####
use strict;
use XML::XPath;
my $xpath = XML::XPath->new(ioref => \*DATA);
my $nodes = $xpath->find('//table[@border=0][@align="center"]');
print XML::XPath::XMLParser::as_string($nodes->get_nodelist);