in reply to How to convert <,&,>,",' into XML &lt;,&amp;,&gt;,&quot ..

encode_entities($input, q{<>&"'}) from HTML::Entities will do the trick.