use XML::Parser; $xml = "<!DOCTYPE z [<!ENTITY x 'marks the spot'> ]> <z>X &x;</z>"; $p = new XML::Parser(Handlers => { Char => \&Text }); $test = 1; $p->parse($xml); $p = new XML::Parser(Handlers => { Char => \&Text, Default => \&Def, Start => \&STag}, NoExpand => 1); $test = 2; $p->parse($xml); sub STag { $sawRoot = 1; } sub Text { print "Text $test: {$_[1]}\n"; } sub Def { print "Default $test: {$_[1]}\n" if $sawRoot; } Text 1: {X } Text 1: {marks the spot} Text 2: {X } Default 2: {&x;} |