How do I Set XmlArrayItem Element name for a List implementation?

后端 未结 3 896
星月不相逢
星月不相逢 2020-12-20 12:06

I want to create a custom XML structure as follows:


    

I\'ve created an implementation of <

3条回答
  •  既然无缘
    2020-12-20 12:39

    Assuming you are using XmlSerializer, if all you want to do is change how your HotelBasic class is serialized, you can use XmlTypeAttribute:

    [XmlType(TypeName = "Hotel")]
    public class HotelBasic
    {
        public string Name { get; set; }
    }
    

    When used with your HotelList class it will be serialized as:

    
      
        One
      
      
        Two
      
    
    

提交回复
热议问题