I am new to C# WebAPIs and I am trying to serialized XML on the return of data from API. Below is a model I have and the XML is not being serialized. The model is being serialized, however only the property names, not the XmlElement attributes on the properties. The JSON serialization works just fine, just not XML.
To return the data in the Controller Action, I am using Request.CreateResponse<Type>(code, data);
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Newtonsoft.Json;
[XmlType("Chapter")]
public class Chapter
{
[XmlElement("ChapterNumber"), JsonProperty("ChapterNumber")]
public Int32 number { get; set; }
[XmlArray("Verses"), XmlArrayItem("Verse"), JsonProperty("Verses")]
public List<Verse> verses { get; set; }
}
Any ideas?