Newline characters not recognized when parsing external XML file
Posted by Dennis on Aug 13, 2008 in ActionScript, Flash, Flex • 2 commentsI encountered this problem when implementing a workaround for the multiline unicode text wrapping bug. I use newline characters (”\n”) to break up the text manually. When I load the XML file and parse it in my Flex app, newline characters are displayed in the text field. Tracing out the string displays “\n” and not an escaped version like “\\n”. Oddly enough this simple replace fixes the problem:
var myText : String = String( root.somenode.anothernode );
myText = myText.replace(/\\n/g, "\n");




Thanks!
Worked fro me with
myText = myText.replace(/\r\n/g, “\n”);
Thanks for this post. This saved me a ton of work around code.