How to remove schema node in web api if return format is xml?
<p>I have a web api method that takes format as a parameter that provides returning both xml and json.The data type that method return is DataTable.In json format everything looks fine but in xml format the schema of datatable and some other attributes in xml nodes also returning.How to return simple xml that includes only data of datatable?Also, I am using QueryStringMapping in WebApiConfig.</p>

<p>This is WebApiConfig Code</p>

<pre><code>public static void Register(HttpConfiguration config)
{
    config.MapHttpAttributeRoutes();
    config.Routes.MapHttpRoute(
        name: "DefaultApi",
        routeTemplate: "api/{controller}/{action}/{id}",
        defaults: new { id = RouteParameter.Optional }
    );
    config.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("format", "json", new MediaTypeHeaderValue("application/json")));
    config.Formatters.XmlFormatter.MediaTypeMappings.Add(new QueryStringMapping("format", "xml", new MediaTypeHeaderValue("application/xml")));
    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
}
</code></pre>

<p>This is a pseudo code of controller method</p>

<pre><code>[BasicAuthentication]
[Route("api/{tablename}")]
[HttpGet]
public IHttpActionResult Get(string tablename, string orders = "", int limit = 100)
{
    DataTable dt = new DataTable{TableName="resource"};
    //... Database connection and getting result
    return Ok(new Response{ limit = limit,count=dt.Rows.Count, data =dt });
}
</code></pre>

<p>and the Response Model</p>

<pre><code>public class Response
{
    public int limit { get; set; }
    public int count { get; set; }
    public DataTable data { get; set; }

}
</code></pre>

<p>The example of returned xml </p>

<pre><code>   &lt;Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;limit&gt;1&lt;/limit&gt;
    &lt;count&gt;1&lt;/count&gt;
    &lt;data&gt;
    &lt;xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"&gt;
    &lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="resource" msdata:UseCurrentLocale="true"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
    &lt;xs:element name="resource"&gt;
    &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
    &lt;xs:element name="ID" type="xs:long" minOccurs="0"/&gt;
    &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
    &lt;/xs:schema&gt;
    &lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt;
    &lt;DocumentElement&gt;
    &lt;resource diffgr:id="resource1" msdata:rowOrder="0"&gt;
    &lt;ID&gt;1&lt;/ID&gt;
    &lt;/resource&gt;
    &lt;/DocumentElement&gt;
    &lt;/diffgr:diffgram&gt;
    &lt;/data&gt;
    &lt;/Response&gt;
</code></pre>

<p>To sum up, I want to return only resource nodes in data node without any attribute.</p>