in reply to Special characters in perl/cgi

Just replace & with &amp; and < with &lt;. What you show as XML is not a real XML, because &reg; is not an XML entity. You want
<error>Missed &amp;reg; in line 2</error> <error>Missed &lt;h1> tag in line 8</error>