我有一个如下的 XML 结构:
<buttons>
<button>
<text>Yes</text>
<type>Submit</type>
</button>
<button>
<text>No</text>
<type>Cancel</type>
</button>
</buttons>
我有如下反序列化类:
[XmlRoot("PageData")]
public class PageData
{
[XmlArray("buttons")]
[XmlArrayItem("button")]
public List<Button> Buttons { get; set; }
}
public class Button
{
[XmlElement("text")]
public string Text { get; set; }
[XmlElement("type"))]
public PANELBUTTONTYPE Type { get; set; }
}
public enum PANELBUTTONTYPE
{
[XmlEnum(Name = "Submit")]
Submit,
[XmlEnum(Name = "Cancel")]
Cancel,
}
当我反序列化数据时,出现以下错误
{“反映属性‘按钮’时出错。”}