現在の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))]
どうすればこれを解決できますか?ありがとう)
属性の追加:
public class ObjectList
{
[XmlElement("Item")]
public List<Item> Items { get; set; }
[XmlElement("DifferentItem")]
public List<DifferentItem> DifferentItems { get; set; }
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加