我有下面的代碼,但無法反序列化,你能看到我要去哪裏錯了嗎?它只捕獲第一個數組項目上的第一條記錄。無法反序列化XML
[XmlRootAttribute("Booking")]
public class Reservation
{
[XmlArray("Included")]
[XmlArrayItem("Meals")]
public Meals[] Food { get; set; }
[XmlArrayItem("Drinks")]
public Drinks[] Drink { get; set; }
}
public class Meals
{
[XmlAttribute("Breakfast")]
public string Breakfast { get; set; }
[XmlAttribute("Lunch")]
public string Lunch { get; set; }
[XmlAttribute("Dinner")]
public string Dinner { get; set; }
}
public class Drinks
{
[XmlAttribute("Soft")]
public string Softs { get; set; }
[XmlAttribute("Beer")]
public string Beer { get; set; }
[XmlAttribute("Wine")]
public string Wine { get; set; }
}
下面是相關的XML
<?xml version="1.0" standalone="yes"?>
<Booking>
<Included>
<Meals
Breakfast="True"
Lunch="True"
Dinner="False">
</Meals>
<Drinks
Soft="True"
Beer="False"
Wine="False">
</Drinks>
</Included>
<Included>
<Meals
Breakfast="True"
Lunch="False"
Dinner="False">
</Meals>
<Drinks
Soft="True"
Beer="True"
Wine="True">
</Drinks>
</Included>
</Booking>
我有點新手的所以任何幫助將是巨大的,通過多次exmaples你已經在網上我還沒有去過拖網後不幸能夠弄清楚這一點。
非常感謝,我怎麼能把這個包裝成一個閱讀器? – user1641194
@ user1641194抱歉沒有看到您的評論。猜猜你現在想通了。無論如何,更新我的答案。 – jbl