I am wondering if there is a way to use the XmlSerializer to deserialize objects with different casing.
Lets say my object is
Class A
{
public String Str{get;set;}
}
I have the following XML files, id like to deserialize:
<root><StR>Hello</StR></root>
<root><STR>Hello</STR></root>
<root><str>Hello</str></root>
Any Suggestions/Ideas? Also approachs manipulating the DOM, etc are welcome :)
Regards
XML tags are case sensitive.
Yes, you can tell the XmlSerializer to ignore namespaces during de-serialization.
Since XmlSerializer is one of the few thread safe classes in the framework you really only need a single instance of each serializer even in a multithreaded application. The only thing left for you to do, is to devise a way to always retrieve the same instance.
The XmlSerializer enables you to control how objects are encoded into XML, it has a number of constructors. If you use any of the constructors other than the one that takes a type then a new temporary assembly is created EVERY TIME you create a serializer, rather than only once.
XML is case sensitive, so in this case I'd say it would fail. So you should cleanse the data using regex as the DOM will have issues with the XML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With