views:

871

answers:

3

In actionscript 3, when trying to load an XML file like

<Element><Property> a </Property></Element>

the value in the node "property" will be just "a", trailing and leading whitespaces are removed.

I did what http://bugs.adobe.com/jira/browse/ASC-3125 recomends, with no success. Any ideas?

+2  A: 

I believe if you put it inside CDATA tags, you'll get the whitespace.

<Element><Property><![CDATA[ a ]]></Property></Element>
quoo
This would probably work but the syntax is ugly. The idea was to keep my xml simple
federubin
It may be a few extra characters in your code, but it'd save you from the bugs grapefrukt mentioned. It's also the standard solution for something like this. http://www.w3schools.com/XML/xml_cdata.asp
quoo
A: 
XML.prettyPrinting = false

Should work just fine, this is what I use for this exact problem. But do note that this is a global setting and can result in new bugs in other places in your app.

grapefrukt
A: 

As described before, XML.prettyPrinting didn't work. Finally it got fix by adding XML.ignoreWhitespace = false;

After that line of code, the trailing spaces are not removed.

federubin