I\'m trying to get my httphandler to print out an XML file with the format:
...
You need to use the overloaded constructor that takes in a XmlAttributeOverrides
and make sure you override the name of the ScheduledShow
class.
I found an answer to my question here:
http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/4b228734-a209-445a-991c-0420b381ac93
I just used [XmlType("")]
and that worked.
using System;
using System.Xml.Serialization;
namespace CommunityServer.Scheduler
{
[XmlType("ScheduledShowElement")]
public class ScheduledShow
{
...
}
}
[XmlRoot(...)]
only affects the outermost element (<ScheduledShows>...</ScheduledShows>
). I suspect you want [XmlElement(...)]
. Of course, another way is to write an object wrapper:
[XmlRoot("SheduledShows")]
public class Shows {
[XmlElement("SheduledShowElement")]
public List<Show> Shows {get;set;}
}
And serialize this wrapper object instead of just a list.