Search code examples
actionscript-3html-parsinghtml-encode

How do I html encode text inside Action Script 3?


I have an app that builds XML, the text nodes values are coming from the users.
How would I HTML encode that input to avoid bad characters?
Preferably looking for a built in solution in Action Script.


Solution

  • I've used escape() and unescape() for POST variables in the past, not sure if it's the best solution for XML though.

    This method seems promising: http://www.markledford.com/blog/2009/02/25/as3-htmldecode-htmlencode-xml-hack/

    You can also try converting the string to a textnode as mentioned in How do you encode XML safely with ActionScript 3?