in reply to Strip out value between xml tags

XML::Twig
use warnings; use strict; use XML::Twig; my $xml = <<XML; <top> <PrvsNtfctnId><Id>92190602</Id></PrvsNtfctnId> <CorpActnGnlInf> <CorpActnEvtId>12345678</CorpActnEvtId> <OffclCorpActnEvtId>USJJT</OffclCorpActnEvtId> </CorpActnGnlInf> </top> XML my $twig = XML::Twig->new( twig_handlers => { CorpActnEvtId => sub { print $_->text(), "\n" } + } ); $twig->parse($xml); __END__ 12345678