use strict; use warnings; use XML::Rules; XML::Rules->new(rules => { Sender => sub { print "sender: ", $_[1]->{_content}, "\n"; }, Receiver => sub { print "sender: ", $_[1]->{_content}, "\n"; }, FileType => sub { delete $_[1]->{_content}; print " file: ", (keys(%{$_[1]}))[0], "\n"; return; }, # it would work without the following rules, but is more efficient with them 'InitTAP,FatalRAP,ReTxTAP' => 'content', '_default' => '', })->parsefile( "fdata.xml");