I have a .NET application written in C# that saves information in XML format. The application serializes the application data into xml. The application contains a textbox where the user is free to enter any text. I have cases where users have managed to enter characters, mostly when they copy and paste text from other applications into the textbox, where the xml document becomes corrupted. Is there a general approach to manage illegal characters in xml documents without having to filter them out in every textbox on entry.
Sample from document thats corrupted
<Propery> <Name>Alimentação Controlador</Name> <Value>24</Value> <Unit>Vca</Unit> </Propery> Document is serialized with ASCIIEncoding.UTF8
encodingdoes the XML document declare? How do you produce the XML (do you use an XML library, or do you generate it directly)?