2

I Have a XML string

<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>

and class

[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; }
}

When I deserialize xml to object, "Feature" has no value at all. I want it to be an array of strings.

1 Answer 1

1

Try this:

[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; }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.