2017-10-27 4 views
2

をデシリアライズ私は、XML文字列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をデシリアライズするとき、 "機能" は、すべての値がありません。私はそれを文字列の配列にしたい。

答えて

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; } 
} 
+0

はありがとうございました! –