Removing CDATA tag from XmlNode

Niv picture Niv · Aug 4, 2013 · Viewed 11.7k times · Source

I have an XmlNode which represents the following xml for example:

XmlNode xml.innerText =
<book>
<name><![CDATA[Harry Potter]]</name>
<author><![CDATA[J.K. Rolling]]</author>
</book>

I want to change this node so that it'll contain the following:

XmlNode xml.innerText =
<book>
<name>Harry Potter</name>
<author>J.K. Rolling</author>
</book>

Any ideas?
Thanks!

Answer

No Idea For Name picture No Idea For Name · Aug 4, 2013

well, if it's exactly how you put it, then it's easy:

xml.innerText = xml.innerText.Replace("![CDATA[","").Replace("]]","");
xmlDoc.Save();// xmlDoc is your xml document