#NOTE: the first entry here is an extended regex that says, match an & that is NOT followed by between 2 and 4 word characters and a semicolon. #This should prevent it from double-encoding entites that already exist and hence corrupting the XML. my @entities_bare=qw/&(?!\w{2,4};) " ' < >/; my @entities_encoded=qw/& " ' < >/; sub encode_entities { my $string=shift; #print "trace: in encode_entities\n"; for(my $n=0;$n