You will need to decorate
Condition
class with proper C# attributes. The class must have a
XMLType(Name="NameOfChoice")
attribute. All the properties that you need to be serialized as XML attributes, must be decorated with
XMLAttribute(Name="AttributeName")
.
While serializing, you can use this:
new XmlSerializer(typeof(List<Condition>), new XmlRootAttribute("Conditions"));
Once serialized, your XML would look like:
<Conditions>
<NameOFChoice AttributeName="ValueOfAttribute" />
<NameOFChoice AttributeName="ValueOfAttribute" />
<NameOFChoice AttributeName="ValueOfAttribute" />
</Conditions>