I have a problem setting a cdata node with jquery. Getting cdata is easily done with the .text() function, but if I use .text('jquery > handy') it doesn't create a cdata node.
This is my procecure: I get form data in xml to load in a form something like this:
<formdata>
<field id="title"><![CDATA[Some title]]></field>
<field id="description"><![CDATA[Some description]]></field>
</formdata>
I use cdata nodes because a field can contain all kinds of special chars. Then I load the data in the form by getting the node content with .text()
If the user posts the form, I update the xml and convert it to a sting to post it to the server. I know I could just post the fields, but I have some good reasons to put it in an xml document. Everything works very well, but not if the user does some input with special characters. This is how i set the value of the node (in this example the "descriptioon node")
domdoc.find('field[id="description"]').text($("#description").val());
So the node used to be cdata, but the .text() function removes that. I alo tried this:
domdoc.find('field[id="description"]').text('<![CDATA[' + $("#description").val() + ']]>');
This also doesn't work because .text() changes < to >
does anyone has a solution? My inspiration is gone.....
Thanks, Simon