Parse CData from XML in C#
<p>Am trying to parse my xml which has CData tag as the value for one of its nodes. My XML structure is as below.</p>

<pre><code>&lt;node1&gt;
&lt;node2&gt;
&lt;![CDATA[ &lt;!--@@@BREAK TYPE="TABLE" @@@--&gt; &lt;P&gt;&lt;CENTER&gt;... html goes here.. ]]&gt;
&lt;/node2&gt;
&lt;/node1&gt;
</code></pre>

<p>My code is as below. When I parse I get response with CData tag and not the value in the CData tag. Can you pls help me fix my problem? </p>

<pre><code>XDocument xmlDoc = XDocument.Parse(responseString);
XElement node1Element = xmlDoc.Descendants("node1").FirstOrDefault();
string cdataValue = node1Element.Element("node2").Value;

Actual Output: &lt;![CDATA[ &lt;!--@@@BREAK TYPE="TABLE" @@@--&gt; &lt;P&gt;&lt;CENTER&gt;... html goes here.. ]]&gt;

Expected Output:  &lt;!--@@@BREAK TYPE="TABLE" @@@--&gt; &lt;P&gt;&lt;CENTER&gt;... html goes here..
</code></pre>

<p>I was not sure if System.XML.Linq.XDocument was causing the problem. So I tried XMLDocument version as below.</p>

<pre><code>XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseString);
XmlNode node = xmlDoc.DocumentElement.SelectSingleNode(@"/node1/node2");
XmlNode childNode = node.ChildNodes[0];
if (childNode is XmlCDataSection)
{}
</code></pre>

<p>And my if loop returns false. So looks like there is something wrong with my xml and it is actually not a valid CData? Pls help me fix  the problem.
Pls let me know if  you need more details.</p>