<div dir="ltr">I'm sure, that embedded Javascript understands &gt; and &lt; instead of > and < characters, so<div><br></div><div><script></div><div>if (a &gt b) alert("a greater than b");</div>
<div></script></div><div><br></div><div>should work.</div><div><br></div><div>You may also try Mochiweb's HTML parser/serializer, which is much simpler and faster, than xmerl</div><div><a href="https://github.com/mochi/mochiweb/blob/master/src/mochiweb_html.erl">https://github.com/mochi/mochiweb/blob/master/src/mochiweb_html.erl</a><br>
</div><div><br></div><div>Tree = {<<"html">>, [{<<"lang">>, <<"en">>}],</div><div>            [...child tags...]},</div><div>mochiweb_html:to_html(Tree).</div>
<div><br></div><div>But I'm not sure if it escapes special characters.</div></div>