Entity-escaping Flash text to write to XML

Hello: I’m trying to expand on the Simple XML Editor in Flash to entity-escape the 5 special characters so they can be used in a CMS.

Say I have an XML file with the following node:

<item text=“Apples & Oranges” /> (entity-escaped)

If I entity-escape the ampersand by editing the raw XML file, then when I load the XML node into Flash, Flash displays the data correctly:

Apples & Oranges

However if I entity-escape the ampersand with XML editor in Flash:

var escapedString:String = origString(replace all “&” with “&”)
input_xml.firstChild.lastChild.attributes.text = escapedString;

then send the data to be written to the XML file, Flash ignores the entity-escaping and displays:

Apples & Oranges

XML is encoded as UTF-8 (no BOM) with a DTD.