use 5.010; use strict; use warnings; use XML::Parser; my $in_title; my $parser = XML::Parser->new( Handlers => { Start => sub { $in_title++ if $_[1] eq 'Title' }, End => sub { $in_title-- if $_[1] eq 'Title' }, Char => sub { say "CHAR: $_[1]" if $in_title }, }, ); $parser->parse(<<'XML'); Company A&B Information Foo XML