I am trying to retrieve a cdata section from an xml document, the format of the xml is like this:
<Configuration>
<ConfigItem>
<Key>Hello World</Key>
<Value><![CDATA[For the value we have a large chunk of XAML stored in a CDATA section]]></Value>
</ConfigItem>
</Configuration>
What I am trying to do is retrieve the XAML from the CDATA section, my code so far is as follows:
XmlDocument document = new XmlDocument();
document.Load("Configuration.xml");
XmlCDataSection cDataNode = (XmlCDataSection) document.SelectSingleNode("//*[local-name()='Value']").ChildNodes[0];
String cdata = cDataNode.Data;
However the cdata string has been truncated and is incomplete, I guess because the actual cdata is too large to fit in the string object.
Whats the correct way to do this?
EDIT:
So my original assumption that the string was too long was incorrect. The problem now is that my CDATA contains a nested CDATA within it. Reading online it appears that the proper way to escape the nested cdata is to use ]]]]><![CDATA[>
which this xml is using, but it seems like when I select the node it is escaping at the wrong place.