Serialize c# object in XML using variable content as attribute name



I have the following c# object:



class Modification {
public string Name;
public string Value;
}


I want to use the serializer to serialize my object the following way:



<name>value</name>


Example: Let's say we set those variables to



Name = "Autoroute"
Value = 53


I want the xml to look like:



<Autoroute>53</Autoroute>


I saw somewhere that this feature is not supported by the serializer, but is there a way to overload the serializer to allow this kind of behavior ?


Changing the XML structure is not an option since it is already a convention.


No comments:

Post a Comment