XML Deserialization of string elements with newlines in C?

It seems it is working as intended. From IgnoreWhitespace documentation.

It seems it is working as intended. From IgnoreWhitespace documentation: White space that is not considered to be significant includes spaces, tabs, and blank lines used to set apart the markup for greater readability. Basically, what it does is preserves (when set to false) whitespaces in between elements such as: Text The newline between and will be returned by reader.

Set IgnoreWhitespace to true, and it won't. To achieve your goal you'll have to do programmatic trimming, as mentioned by Kirill. When you think about it, how is reader supposed to know whether whitespace of pure string content of element (as in your examples) is just for intending purposes or actual content..? For more reading on ignoring whitespaces you may want to take a look here and here.

You can create custom XmlTextReader class: public class CustomXmlTextReader : XmlTextReader { public CustomXmlTextReader(Stream stream) : base(stream) { } public override string ReadString() { return base.ReadString().Trim(); } }.

Try using XmlTextReader for deserialization with the WhiteSpaceHandling property set to WhiteSpaceHandling. None and Normalization = true.

Unfortunately XmlTextReader with WhiteSpaceHandling. None had no effect – Jordan Oct 20 at 16:07 what about setting Normalization = true? It's false by default.

I think this should convert \n to white space. – Andrew Church Oct 20 at 16:34 Normalization = true converts "\r\n" to "\n" but leaves the newline in there. XmlReaderSettings.

IgnoreWhitespace also removes the "\r" but I couldn't test the combination of the two, since I can only seem to add an XmlReaderSettings instance to a plain XmlReader and not an XmlTextReader (the constructor has no settings parameter, and the settings property has no setter) – Jordan Oct 20 at 16:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions