views:

34

answers:

1

I remember doing it before, so I guess I'm missing something here. XMLNode's nodeType property only support ELEMENT_NODE and TEXT_NODE, and if I try to add the CDATA section to the XMLNode as a string it get escaped.

var node:XMLNode = new XMLNode(3, "<![CDATA[some text and <tags> here]]>");

What I get is a TEXT_NODE with the following value:

&lt ;![CDATA[some text and &lt ;tags&gt ; here]]&gt ;

which isn't even a valid value for a TEXT_NODE

A: 

It will not parse, you may need a backway of doing it.

Trial one : add your node content as a string

var sometext:String = 'some text and <tags> here';

add a blank XMLNode to your document and then use xml.replace

xml.replace('blanknode','<blanknode><![CDATA[' + sometext + ']]></blanknode>');

Trial two: return it from a XML return type function into the XMLNode

Update

var sometext:String = 'some text and <b>bold</b> here';
        var nodeblank:XMLNode = new XMLNode(1,insert(sometext));
        trace(nodeblank);


        var txt:TextField = new TextField();
        txt.htmlText = nodeblank.nodeName;
        addChild(txt);

This shows in the TextField -> some text and bold here

public function insert(s:String):XML {
            var x:XML = new XML("<![CDATA[" + s + "]]>");
            return x;
    }
phwd
If I understand correctly you're talking about using the XML class, but this way I'll lose all the XMLDocument and XMLNode functionality won't I?Can you please elaborate on that "Trail two" solution?
Leeron
yip that is correct if you need backwards compatibility with AS2 then 1 would not work.
phwd