How to rename XML attribute that generated after serializing List of objects

后端 未结 4 1147
我寻月下人不归
我寻月下人不归 2020-12-01 12:24

I am serializing List of objects List , and XmlSerializer generates attribute, I want rename it or rem

4条回答
  •  甜味超标
    2020-12-01 12:37

    You can add an additional parameter to the XmlSerializer constructor to essentially name the root element.

    XmlSerializer xsSubmit = new XmlSerializer(typeof(List), new XmlRootAttribute("DropDownOptions"));
    

    This would result in the following structure:

     
        
          1
          foo
        
        
          2
          bar
        
    
    

提交回复
热议问题