Hello,
I am saving some text from a string into a XML element.
For example:
var s:String = "Hello ";
var xml:XML = <root>{s}</root>;
I would like the following to happen:
trace(xml); // prints "Hello " (without quotes)
Unfortunately, E4X trims the whitespace. I would like my XML object
to be <root><![CDATA[{s}]]></root> so that the space (maybe?)
wouldn't be trimmed, but I cannot use a CDATA block since it occurs
inside a <mx:Script><![CDATA[ ... ]]></mx:Script> already.
Is there a way to add a CDATA block to an E4X XML object?
P.S. As a workaround, I can escape() the string before adding it,
and unescape() afterwards, but this seems ugly and loses the human-
readability.