Actionscript stripping whitespace when it shouldn't
I'm using URLLoader in an ActionScript project to read in some XML. I then process it, and put it into a textfield. Everything looks fine. However, I don't really want the XML to be external to my SWF. So I did this:
var internalXML:XML = <Content><P>It was in <City>Paris</City> that I first
took a <Activit开发者_Go百科y>walk in nature</Activity>.</P></Content>
That is, I took the identical XML and assigned it to an XML object instance directly in my ActionScript. I then run the exact same process. But this time, whitespace has been stripped out between any XML tag content and plain text.
So that the above reads in the textfield: "It was inParisthat I first took awalk in nature."
In both cases I've got XML.ignoreWhitespace = false. I also tried XML.prettyPrinting = false. No help.
Anyone have any idea what could be happening?
Probably the whitespace trimming is taking place at compile time, not run time (hence the ineffectiveness of XML.IgnoreWhitespace).
To have the XML preserved verbatim until runtime (like it was when you were loading it before), just put it into a string:
var internalXML:XML = XML("<Content><P>It was in <City>Paris</City> that I first took a <Activity>walk in nature</Activity>.</P></Content>")
精彩评论