How to add attributes for C# XML Serialization

前端 未结 4 1930
心在旅途
心在旅途 2020-11-30 03:42

I am having an issue with serializing and object, I can get it to create all the correct outputs except for where i have an Element that needs a value and an attribute. Here

4条回答
  •  Happy的楠姐
    2020-11-30 04:29

    Where do you have the type stored?

    Normally you could have something like:

    class Document {
        [XmlAttribute("type")]
        public string Type { get; set; }
        [XmlText]
        public string Name { get; set; }
    }
    
    
    public class _Filter    
    {
        [XmlElement("Times")]    
        public _Times Times;    
        [XmlElement("Document")]    
        public Document Document;    
    }
    

提交回复
热议问题