Newline characters not recognized when parsing external XML file

Posted by Dennis on Aug 13, 2008 in ActionScript, Flash, Flex2 comments

I 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");



Tags: , , ,


2 comments

» Comments RSS Feed
  1. Thanks!
    Worked fro me with
    myText = myText.replace(/\r\n/g, “\n”);

  2. Thanks for this post. This saved me a ton of work around code.

Leave a comment