I have 2 classes:
public class LocalizationEntry
{
public List<TranslationPair> Translations
{
get;
set;
}
}
public class TranslationPair
{
public string Language
{
get;
set;
}
public string Translation
{
get;
set;
}
}
Is it possible to get such a XML using standard serializer?
<LocalizationEntry>
<Translations>
<EN>apple<EN>
<PL>jabłko<PL>
<DE>apfel<DE>
</Translations>
</LocalizationEntry>
I was thinking about something like XmlArrayItem(ElementName=this.Language) attribute but of course this construction is illegal apart from that attribute value cannot be determined in runtime.
Thanks for any help. Surely I can use other structure, but I’m curious is it possible.
To customise the element names is a pain; I would forget about
XmlSerializerhere, as you’d have to useIXmlSerializablewhich is a royal pain. I’d use XElement instead: