3
我的XML消息的樣子:反序列化數組轉換成複雜的對象
<msg>
<reply userid="sales" requestid="2" index="1" pagesize="1000" total="1" type="order">
<order id="12db8625cd4-000" owner="sales">
<qty size="1" working="0"/>
<price limit="0.0"/>
</order>
<order id="12db8636344-000" owner="sales">
<qty size="1000" working="0"/>
<price limit="0.0"/>
</order>
</reply>
</msg>
我如何定義訂單對象從答覆陣列讀?我的物品看起來像:
[XmlRootAttribute("reply")]
public class MessageReply
{
[XmlAttribute("userid")]
public string UserId { get; set; }
[XmlAttribute("requestid")]
public string RequestId { get; set; }
[XmlAttribute("type")]
public string Type { get; set; }
[XmlArrayItem(typeof(Order))]
public List<Order> Orders { get; set; }
}
[XmlRootAttribute("order")]
public class Order
{
[XmlAttribute("id")]
public string Id { get; set; }
[XmlAttribute("owner")]
public string Owner { get; set;}
[XmlAttribute("assignee")]
public string Assignee { get; set; }
[XmlAttribute("instrumentid")]
public string InstrumentId { get; set; }
[XmlAttribute("side")]
public string Side { get; set;}
[XmlAttribute("type")]
public string Type { get; set; }
}
在我的情況下,訂單應該在一個單獨的元素標籤訂單。我想從回覆元素中讀取它們。你有什麼想法在我的對象XML屬性中改變什麼?
非常感謝。你救了我的一天:) – 2011-01-25 12:45:03