4
我有一個奇怪的行爲與XElement。看起來Value屬性將新行表達式\ r \ n更改爲unix像表達式\ n。這是爲什麼?爲什麼XElement Value屬性將 r n更改爲 n?
string valueString = "abc\r\ndef";
string xmlString = "<desc>abc\r\ndef</desc>";
XElement xElement = XElement.Parse(xmlString);
string toString = xElement.ToString(); //as expected same value as xmlString
string xElementValue = xElement.Value; //contains abc\ndef instead of abc\r\ndef
謝謝!
你對它的設計在xml:http://www.w3schools.com/Xml/xml_syntax.asp。此外,我嘗試使用Parse方法使用LoadOptions.PreserveWhitespace,但我得到相同的行爲。非常感謝! – pcius 2010-11-18 22:55:14
也可以嘗試在XML內添加它,如 abc \ r \ ndef ,看看它是否有幫助 –
veljkoz
2010-11-19 08:49:41