I was trying to create a CDATA section with an XML file, and had something like this:

var pinEntrySubmitBtnURL = copyXML.CreateElement(“pinEntry_submitBtn_URL”);
var pinEntrySubmitBtnURLContent = copyXML.CreateTextNode( “<![CDATA[hidden_pin.ashx]]>”);
pinEntrySubmitBtnURL.AppendChild(pinEntrySubmitBtnURLContent);
copyNodes.Add( pinEntrySubmitBtnURL );

All of my intended XML data was coming out as escaped XML:

&lt;![CDATA[hidden_pin.ashx]]&gt;

It took me a few minutes to track this down, but eventually Intellisense gave me the answer. Turns out you need to use the CreateCDataSection function instead:

var pinEntrySubmitBtnURL = copyXML.CreateElement(“pinEntry_submitBtn_URL”);
var pinEntrySubmitBtnURLContent = copyXML.CreateCDataSection( “hidden_pin.ashx”);
pinEntrySubmitBtnURL.AppendChild(pinEntrySubmitBtnURLContent);
copyNodes.Add( pinEntrySubmitBtnURL );

I spent some time searching on the net and couldn’t find any clear examples of this – so hopefully this helps you out.

Shendy.