Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XmlSerializer -> case insensitive

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

like image 338
Jaster Avatar asked Nov 08 '10 10:11

Jaster


People also ask

Is XML case sensitive language?

XML tags are case sensitive.

Can I make XmlSerializer ignore the namespace on Deserialization?

Yes, you can tell the XmlSerializer to ignore namespaces during de-serialization.

Is XmlSerializer thread safe?

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.

What is XmlSerializer C#?

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.


1 Answers

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.

like image 134
Preet Sangha Avatar answered Sep 28 '22 04:09

Preet Sangha