I was able to use attributes to get everything I needed, although my situation is relatively simple. For example, to make deserialize nodes with dashes in them, and then to be able to serialize the same node name, I used this:
[XmlElement(ElementName = "short-name")] [SerializeAs(Name = "short-name")] public string shortName { get; set; }
So, in your example, serialization does not match [XmlElement("elementName")] . Instead, you will need to use [SerializeAs(Name = "elementName")] .
I found this by trolling test code in a RestSharp project.
source share