XmlRoot() for Xml Serilization does not work

前端 未结 3 2060
旧时难觅i
旧时难觅i 2020-12-18 22:58

I\'m trying to get my httphandler to print out an XML file with the format:


    ...         


        
3条回答
  •  独厮守ぢ
    2020-12-18 23:26

    [XmlRoot(...)] only affects the outermost element (...). I suspect you want [XmlElement(...)]. Of course, another way is to write an object wrapper:

    [XmlRoot("SheduledShows")]
    public class Shows {
        [XmlElement("SheduledShowElement")]
        public List Shows {get;set;}
    }
    

    And serialize this wrapper object instead of just a list.

提交回复
热议问题