I have serializable class:
[XmlRoot(ElementName = "News"), XmlType("News")] // I tried many attributes...
public class News
{
[XmlElement("Article")]
public List<Article> Articles { get; set; }
}
And method for serialization:
public static void SerializeToXML(Object obj)
{
XmlSerializer ser = new XmlSerializer(obj.GetType());
...
}
I would like to have the first XML element <News> but it is <ArrayOfArticle>.
Note, I've found many similar answers but it seems I have another problem...
If I use ...XmlSerializer(typeof(News)); instead of ...obj.GetType() everything is okay. But there is something wrong with obj.GetType(). It causes that (ser.mapping).ElementName is "ArrayOfArticle". What is the difference?