Search code examples
xmlstringactionscript-3apache-flexflex4

How to remove break on converting XML to String type in Flex?


I want to convert one XML type value to String type value and for that I am using toString() method to achieve that but problem is that on converting from XML to String I am getting some "\n"(Break statement) in that string variable.

But I don't know why that is coming, I am currently using the following codes for conversion:

My XML is:

var text:XML = new XML(<HTML>
<BODY>
<P ALIGN="left">
  <FONT>
    <FONT SIZE="32">
      Some Text Here
    </FONT>
  </FONT>
</P>
</BODY>
</HTML>);

Following code I am using for converting XML to String:

var textString:String = (text.normalize()).toString();

But if I am checking the variable textSring then I am getting the following result:

<HTML>\n  <BODY>\n    <P ALIGN="left">\n      <FONT>\n        <FONT SIZE="32">Some Text Here</FONT>\n      </FONT>\n    </P>\n  </BODY>\n</HTML>

But I don't know why "\n" is coming after converting to String.

If anybody can find where I am doing wrong so that I am getting the result like this and how to resolve this problem please help me to solve.


Solution

  • this solves the problem

    var textString:String = (text.normalize()).toString().split("\n").join("");