actionscript-3jsfl

Avoid escaping in xml


I read a xml file contains

<![CDATA[<property id="SubClass"></property>]]>

When I write back into file , it will become:

&lt;property id="SubClass"&gt;&lt;/property&gt;

How can I avoid it and write back the original string ? I mean just write back:

<![CDATA[<property id="SubClass"></property>]]>

P.S.

I used alert() to display it before write to file.It's all right but without .Like:

<property id="SubClass"></property>

The writing back function is following:

var xmlObj = <![CDATA[<property id="SubClass"></property>]]>;
FLfile.write(path, xmlObj);//unescape() is useless there.

FLfile is an object in jsfl(FlashJavaScript).


Solution

  • If you run into a problem where the parser is replacing special symbols of XML syntax, save the XML as a String opposed to XML object to preserve the data.