3 Replies Latest reply on Sep 9, 2013 10:30 AM by gregorylafrance

    \n in result handler xml

    gregorylafrance

      When I extract the following from result handler xml, the \n display as \n in TextArea. How can I extract from result so they are actually line breaks?

       

      <EmailText>Thank you for reporting this to us.\nPlease include the city you are in.</EmailText>

       

      private function onGotResult(event:RestServiceResponse):void {

          var defaultEmailTextValue:String = resultData..EmailText;

      }

        • 1. Re: \n in result handler xml
          Aaron Beall Level 3

          If you're actually seeing the character sequence "\n" it means somewhere along the lines a newline is being replaced by that character sequence... if you don't know where that's happening (I suspect somewhere on the server, not the Flex framwork) then your simplest solution would be to replace that character sequence with a newline:

           

          defaultEmailTextValue = defaultEmailTextValue.replace(/\\n/g, "\n");

          • 2. Re: \n in result handler xml
            gregorylafrance Level 1

            Tried that, \n still displayed in textarea.

             

            One thing I tried holds promise. If the text has line breaks without characters, like this:

             

            This is the first line.

             

            This is the second line.

             

            Then no problem, EXCEPT that when the text is rendered in the text area an extra line break seems to be added. In fact everytime you save another line break is added. So save (which returns you to another page) and then return to the page with the text area, and you see this:

             

            This is the first line.

             

             

            This is the second line.

             

            Save again and you see this:

             

             

            This is the first line.

             

             

             

            This is the second line.

             

            I've done some tracing, and I can't find anywhere this is added, certainly not in my code.

            • 3. Re: \n in result handler xml
              gregorylafrance Level 1

              This latest issue might be a problem in our code. Thanks for your input, it did help!