【发布时间】:2017-10-06 16:14:49
【问题描述】:
你能帮我反序列化当前的xml吗:
<ObjectList>
<Item Attr1="1"/>
<Item Attr1="2"/>
<DifferentItem Attr2="5"/>
</ObjectList>
我想反序列化成这样的结构
public class ObjectList
{
public List<Item> Items { get; set; }
public List<DifferentItem> DifferentItems { get; set; }
}
public class Item
{
public string Attr1 { get; set; }
}
public class DifferentItem
{
public string Attr2 { get; set; }
}
我尝试了属性,但没有成功
[XmlArray("ObjectList")]
[XmlArrayItem("Item", typeof(Item))]
我该如何解决这个问题? 谢谢)
【问题讨论】:
标签: c# .net xml deserialization