How to write CData in xml

Posted by Rajesh Rolen- DotNet Developer on Stack Overflow See other posts from Stack Overflow or by Rajesh Rolen- DotNet Developer
Published on 2011-01-13T11:29:48Z Indexed on 2011/01/13 11:53 UTC
Read the original article Hit count: 303

Filed under:
|

i have an xml like :

<?xml version="1.0" encoding="UTF-8"?>
<entry>
    <entry_id></entry_id>
    <entry_status></entry_status>
  </entry>

i am writing data in it like:

XmlNode xnode = xdoc.SelectSingleNode("entry/entry_status");
xnode.InnerText = "<![CDATA[ " + Convert.ToString(sqlReader["story_status"]) + " ]]>" ;    

but its change "<" to "&lt" of CDATA. Please tell me how to fill values in above xml as a CData format.

i know that we can create CDATA like :

XmlNode itemDescription = doc.CreateElement("description");
XmlCDataSection cdata = doc.CreateCDataSection("<P>hello world</P>");
itemDescription.AppendChild(cdata);
item.AppendChild(itemDescription);

but my process is to read node of xml and change its value not to append in it. Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml