C # - deserializing an xml string, there is an error in the xml document (1,2)

I am trying to deserialize an xml string in C # using the following

XmlSerializer serializer = new XmlSerializer(typeof(Application)); App = (Application)serializer.Deserialize(xmlString); 

Everything works well when the xml is pretty printed, but when I have all the xml in a separate deserialization, error with error

There is an error in the XML document (1, 2). The name cannot begin with the character '.' character, hexadecimal value 0x00. Line 1, position 2. "

I checked that xml is valid as such.

Does anyone know what can be done to overcome this problem?

+4
source share
1 answer

Most likely you are loading the UTF-16 file as UTF-8, and as a result every second character is 0.

If this is true, this can happen if you saved the original XML without specification (byte order) or explicitly used the wrong encoding, while the openeing file ...

+9
source

All Articles