in reply to Fetch particular xml message from log

#!perl use strict; use XML::Twig; my $xml = q!<xml><test> <name> 111 </name><book> 234 </book> </test><test> <name> 111 </name><book> abc </book> </test></xml>!; my $t = XML::Twig->new( twig_handlers => {'test/book[string()=~/abc/]'=> \&book} ); $t->parse($xml); sub book { my($t,$book) = @_; $book->parent->print; print "\n"; }