查看我的 XML 示例,我该如何反序列化它?但我需要反序列化 Xml Element 数组。我怎么做?
<hotels num="1">
<hotel num="1" item="2"></hotel>
<hotel num="2" item="2"></hotel>
<hotel num="3" item="2"></hotel>
<hotel num="4" item="2"></hotel>
<hotel num="5" item="2"></hotel>
</hotels>
[Serializable]
[XmlRoot("hotels")]
public class Hotels
{
[XmlElement("id")]
public string id { get; set; }
[XmlElement("hotel")]
public Hotel hotel { get; set; }
}
[Serializable]
[XmlRoot("hotel")]
public class Hotel
{
[XmlElement("id")]
public string id { get; set; }
[XmlElement("item")]
public string item { get; set; }
}