How to write CData in xml
- by Rajesh Rolen- DotNet Developer
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 "<" 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