Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

NewLine character in XCData

$
0
0

Let's take the code:

 

string

xml = "<node><![CDATA[line1\r\nline2]]></node>";

XDocument doc = XDocument.Parse(xml);

XCData data = doc.Element("node").FirstNode asXCData;

Console.WriteLine(data.Value);

 

The console output seems to be OK, but the real content of data.Value is "line1\nline2", the carriage return \r characted has been removed. I have tried different parsing options, but couldn't find how to get the real content. Funny, but the inner xml text in this element is proper, only Value property has this character filtered.

 

I tried the same with System.Xml classes (XmlDocument, XmlCDataSection) and in this case I get the proper results. Does anyone know haw can I get it using XLINQ?


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>