I have a c# MVC model which I would like to serialize to an XML document to look like this:
<Vehicle>
<Type color="red" speed="50mph">Ford</Type>
<Type color="blue" speed="70mph">Toyota</Type>
</Vehicle>
Here is the model:
[Serializable]
public class Production
{
public List<Vehicle> Vehicles { get; set; }
}
[Serializable]
public class Vehicle
{
[XmlAttribute]
public string color { get; set; }
[XmlAttribute]
public string speed { get; set; }
}
Since class Vehicle is not a property what do I need to add to the class to give it a value of for example "ford" or "Toyota"
Right now I have:
var myvehicle = new Vehicle {color = "red", speed = "50mph"};