I am looking for fast way to deserialize xml, that has special characters in it like ö.
I was using XMLReader and it fails to deserialze such characters.
Any suggestion?
EDIT: I am using C#. Code is as follows:
XElement element =.. //has the xml
XmlSerializer serializer = new XmlSerializer(typeof(MyType));
XmlReader reader = element.CreateReader();
Object o= serializer.Deserialize(reader);
What works for me is similar to what @martin-buberl suggested:
Tried something above?
I haven't checked, but this sprang to mind. I managed to de+serialize Data that has åäö etc. U are not talking about tagnames?
I'd guess you're having an encoding issue, not in the
XMLReader
but with theXmlSerializer
.You could use the
XmlTextWriter
and UTF8 encoding with theXmlSerializer
like in the following snippet (see the generic methods below for a way nicer implementation of it). Works just fine with umlauts (äöü) and other special characters.I personally use the follwing generic methods to serialize and deserialize XML and objects and haven't had any performance or encoding issues yet.