title: Return XML response with metadata from asp .net core Web API
body: <p>How can I return an XML response from webAPI written in .net core to have the metadata information at the top. </p>
  
  <p>Required response : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/"
   xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;metadata&gt;
          &lt;item name="AsOfDate" type="xs:string" length="12"/&gt;
          &lt;item name="RateOfReturn" type="xs:double"/&gt;
          &lt;item name="FamAcctIndex" type="xs:string" length="3"/&gt;
          &lt;item name="RowID" type="xs:string" length="1"/&gt;
          &lt;item name="BrM" type="xs:string" length="1"/&gt;
          &lt;item name="ProductLineCode" type="xs:int"/&gt;
      &lt;/metadata&gt;
      &lt;data&gt;
          &lt;row&gt;
              &lt;value&gt;Apr 26, 2002&lt;/value&gt;
              &lt;value&gt;0.210066429&lt;/value&gt;
              &lt;value&gt;JA1&lt;/value&gt;
              &lt;value&gt;F&lt;/value&gt;
              &lt;value&gt;B&lt;/value&gt;
              &lt;value&gt;1&lt;/value&gt;
          &lt;/row&gt;
          &lt;row&gt;
              &lt;value&gt;Apr 27, 2002&lt;/value&gt;
              &lt;value&gt;0.1111111&lt;/value&gt;
              &lt;value&gt;BBB&lt;/value&gt;
              &lt;value&gt;G&lt;/value&gt;
              &lt;value&gt;B&lt;/value&gt;
              &lt;value&gt;2&lt;/value&gt;
          &lt;/row&gt;      
      &lt;/data&gt;
  &lt;/dataset&gt;
  </code></pre>
  
  <p>I have added the following code to accept xml type : </p>
  
  <pre><code>services.AddMvc().AddXmlSerializerFormatters();
  </code></pre>
  
  <p>My API method returns XML without the metadata if I use <code>Accept : application/xml</code></p>