XmlSerialization Collection as Array
问题 I'm trying to serialize a custom class that needs to use multiple elements of the same name. I've tried using xmlarray, but it wraps them in another elements. I want my xml to look like this. <root> <trees>some text</trees> <trees>some more text</trees> </root> My code: [Serializable(), XmlRoot("root")] public class test { [XmlArray("trees")] public ArrayList MyProp1 = new ArrayList(); public test() { MyProp1.Add("some text"); MyProp1.Add("some more text"); } } 回答1: Try just using [XmlElement