I have a problem about XmlSerializer. In my huge XML file, there are some Null characters (\u0000) and so XmlSerializer (Deserializer) gives me an error. I found out that I need to set Normalization to false (via: https://msdn.microsoft.com/en-us/library/aa302290.aspx), so I tried this:
XmlSerializer deserializer = new XmlSerializer(typeof(T));
XmlTextReader reader = new XmlTextReader(filename);
reader.Normalization = false;
return (T)deserializer.Deserialize(reader);
I tried also second possibility, when I used XmlReader, because is also suggested by MSDN, and I tried to set CheckCharacters to false like this:
XmlSerializer deserializer = new XmlSerializer(typeof(T));
XmlReaderSettings settings = new XmlReaderSettings() { CheckCharacters = false };
using (XmlReader reader = XmlReader.Create(filename, settings))
{
return (T)deserializer.Deserialize(reader);
}
`
but both solutions give me the same result: InvalidOperationException on the line and column in XML where is the Null character.
Could you please give me an advice about that? I need to "load" the XML structure to my defined class. Without lines with these characters its working fine.
Thanks! :)
Edit: I forgot to say, that I've tried to load the content to a string and update the string, but inserted content is to big, so I get System.OutOfMemoryException and if I try to parse the file line by line, it's too slow. :(