I am using XmlSerializer to generate XML output for my class. Is it possible to create a custom XMLSerializer that have all the xml nodes in lower case? I do not want to add attributes to every field field from my class to specify the node in lower case.
Thank you,
Angela
It depends how much work you want to do. Adding attributes is the easiest option, but you say you don’t want to do that. You could name the classes with lower-case names, but that is a horrible way of approaching this, IMO.
You can tell
XmlSerializerwhat to do at runtime, by usingXmlAttributeOverrides– but then you need to use reflection to tell it about all the members you want to tweak, but note: if you do this, you must cache and re-use such a serializer; if you create a newXmlSerializerviaXmlAttributeOverridesevery time, you will leak assemblies memory.There’s an example on MSDN