Hey man,

I just hacked this out. it's ugly but works.


   function cdata(string:String):XML{
       return new XML('<![CDATA[' + string + ']]>')
   }

var username = "Jesse";
var lastname = "Warden";

var re:XML =
<nodes>
<node>{username}</node>
<node>{cdata(lastname)}</node>
</nodes>

Peace, Mike


On 6/4/07, Jesse Warden <[EMAIL PROTECTED]> wrote:

  How do I use CDATA with E4X?

Reading CDATA nodes is easy. Sending, however, is hampered by the
fact that I cannot use binding within CDATA nodes, and all text is URL
encoded.

So, if I do this:

username = "Jesse";
lastname = "Warden";

<nodes>
<node>{username}</node>
<node><![CDATA[{lastname}]]></node>
</nodes>

It'll look like this:

<nodes>
<node>Jesse</node>
<node><![CDATA[{lastname}]]></node>
</nodes>

If I try assembling manually, it still URL encodes it:

var request:XML = <request>
<moo>
<goo>Hello</goo>
<pan>3</pan>
</moo>
</request>;
var sup:String = "sup dog";
var s:String = "<![CDATA[";
s += sup;
s += "]]>";
request.moo.appendChild(<gai>{s}</gai>);
trace(request);

This is a problem because I'm sending a URL through E4X with URL
parameters, and it's encoding it twice; basically, my & are becoming
&amp;.

I asked the server guy to just let me send this particular value as an
attribute so we could move on, but... no dice, my problem.

???



--
Teoti Graphix
http://www.teotigraphix.com

Blog - Flex2Components
http://www.flex2components.com

You can find more by solving the problem then by 'asking the question'.

Reply via email to