Geeks With Blogs
Patrice Calve Life's short, have fun

I had a problem where the data serialized got “messed up”.  It was a string that contained control chars (tabs, carriage return, line feed, etc.).

Without anything special, the serializer will just “dump” the content directly in the XML (as is).  Having XML what it is, it ignored these special characters when deserializing.

Let's say that the text to save is:

My name is John Doe”

There XML resulting in the serializer will become:



My name is John Doe</myString>



When it gets deserialized, The Carriage Return gets lost.



Add the following attribute

[XmlElement(DataType = "anyURI")]

public string myString


Posted on Thursday, March 30, 2006 12:50 PM | Back to top

Comments on this post: Controling the Data saved during XmlSerializer

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Patrice CalvĂ© | Powered by: