public static void GenerateSampleXml() { var actions = new List <PiAction>(); actions.Add(new Model.PiAction() { Direction = "forward", Length = "24", Name = "Motor2" }); actions.Add(new Model.PiAction() { Direction = "backward", Length = "24", Name = "Motor2" }); DataModel dataModel = new DataModel(); dataModel.Data = new Data() { PiActions = actions, Enable = false }; XmlSerialiser xmlSerialiser = new XmlSerialiser(); string data = xmlSerialiser.Serialize(dataModel); Console.WriteLine(data); }