Hello, has anyone else noticed that AIR's XML.appendChild() implementation differs in behaviour from the regular Flex/Flash Player? In particular, AIR appears to perform XML escaping of strings, while Flex/FP sort of expects already-escaped Strings?
The following example yields different results in AIR vs Flex: <mx:Script> <![CDATA[ protected function doit(e:Event):void { var x:XML = <outer />; var y:XML = <inner />; y.appendChild('hello <&> test'); x.appendChild(y); txt1.text = x.toString(); txt2.text = x.toXMLString(); } ]]> </mx:Script> <mx:Button click='doit(event)' label='Click' /> <mx:TextArea id='txt1' width="100%" height="50%" > </mx:TextArea> <mx:TextArea id='txt2' width="100%" height="50%" > </mx:TextArea> Output in Flex: <outer> <inner>hello <&> test</inner> </outer> Output in AIR: <outer> <inner>hello &lt;&amp;&gt; test</inner> </outer> Note the double XML encoding in AIR. The AIR behaviour is of course the most correct; one would really expect "y.appendChild('hello <&> test');" to be proper API usage, but that just breaks the flash player. So, to handle arbitrary user input (including stuff that resembles XML markup) to an XML node value in FP it is necessary to manually apply XMl encoding to the string before passing it into appendChild(), but in AIR this naturally results in doubly-encoded text nodes. This is particularly problematic when working with flex library projects that are shared between flex and air projects. Guess I'll need to add some air detection code, and only do the manual XML encoding on the string if running outside of AIR. (Also, trying to use CDATA notes doesn't work either, especially if the text to escape contains ]]>) Comments?