convert html characters back to text in Flash - AS3


Question

I need to generate an editable xml file to supply content to a flash website.

I am generating my file with a html form, and htmlspecialchars e.g.:

    $currentItem = htmlspecialchars(stripslashes($currentItem));

This is to prevent xml entries which would produce the error "XML Parsing Error: not well-formed", such as

<entry title="Words & Things">
---------------------^

It has the side effect of making the flash file display the html codes for the content, rather than the proper characters.

Is there a good way to convert the codes back, once they are read into the Flash file (as3)?

1
3
4/23/2009 11:12:43 PM

Accepted Answer

Maybe try:

public function htmlUnescape(str:String):String
{
    return new XMLDocument(str).firstChild.nodeValue;
}

(Found at: http://www.razorberry.com/blog/archives/2007/11/02/converting-html-entities-in-as3/)

2
4/23/2009 11:25:01 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon