我正在尝试序列化需要使用多个同名元素的自定义类。
我尝试过使用 xmlarray,但它将它们包装在另一个元素中。
我希望我的 xml 看起来像这样。
<root>
<trees>some text</trees>
<trees>some more text</trees>
</root>
我的代码:
[Serializable(), XmlRoot("root")]
public class test
{
[XmlArray("trees")]
public ArrayList MyProp1 = new ArrayList();
public test()
{
MyProp1.Add("some text");
MyProp1.Add("some more text");
}
}