how to deserialize an xml node with a value and an attribute using asp.net serialization

前端 未结 1 1273
深忆病人
深忆病人 2020-12-15 16:48

I have 4 small classes to deserialize xml from an incomming xml poll, to usable classes to build up the poll.

now, i know how to set a property from a class, to matc

相关标签:
1条回答
  • 2020-12-15 17:09

    In AnswerItem, make a property called Value and mark it with the XmlText attribute. This setting will cause the XmlSerializer to read the text in the AnswerItem element into the Value property.

    [Serializable()]
    public class AnswerItem
    {
        [XmlAttribute("Id")]
        public Guid QuestionId { get; set; }
    
        [XmlText]
        public string Value { get; set; }
    }
    
    0 讨论(0)
提交回复
热议问题