我希望有人能帮我解决以下问题。我正在尝试从C#
中的以下xml获取项目描述和值<HouseList>
<House key="Bungalow" description="Bungalow house">
<HouseItem description="Bedroom">4</HouseItem>
<HouseItem description="Bathroom">3</HouseItem>
<HouseItem description="Kitchen">2</HouseItem>
</House>
</HouseList>
目前我正在尝试这个:
[Serializable]
[XmlType(TypeName = "House")]
public class House
{
private string key;
private string description;
private List<HouseItem> items;
......
public List<LinkItem> Items
{
get { return items; }
set { items = value; }
}
[Serializable]
[XmlType(TypeName = "HouseItem")]
public class HouseItem
{
private string value;
private string description;
[XmlAttribute(AttributeName = "description")]
public string Description
{
get { return description; }
set { description = value; }
}
[XmlText(DataType = "string")]
public string Value
{
get { return value; }
set { this.value = value; }
}
}
到目前为止,我还没有对HouseItem的名单进行填充,并且想知道当我出错时是否还有人可以发现?任何帮助或建议表示赞赏!
谢谢!