我有一个XML字符串
<ItemAttributes>
<Binding>Misc.</Binding>
<Brand>Gilbert</Brand>
<Department>mens</Department>
<Feature>Elasticated waist with drawcord</Feature>
<Feature>Two pockets with reinforced stitching at base</Feature>
<Feature>Reinforced seams for strength in wear</Feature>
<Feature>Off set inside leg seam to reduce chaffing</Feature>
<Feature>100% Cotton Twill</Feature>
</ItemAttributes>
和班级
[Serializable()]
public class ItemAttributes
{
public string Binding { get; set; }
public string Brand { get; set; }
public string Color { get; set; }
[XmlArrayItem("Feature")]
public string[] Feature { get; set; }
}
当我将xml反序列化为object时,&#34; Feature&#34;完全没有价值。我希望它是一个字符串数组。
答案 0 :(得分:1)
试试这个:
[Serializable]
public class ItemAttributes
{
public string Binding { get; set; }
public string Brand { get; set; }
public string Color { get; set; }
[XmlElement(ElementName = "Feature")]
public string[] Feature { get; set; }
}