title: ASP 4.0, C# Writing a DataSet as XML Data
body: <p>I am simply trying to load a dataset and output it on a webpage as XML with the schema being written as well. I have been researching to find a way to achieve this without any luck.</p>
  
  <p>The code I am using is:</p>
  
  <pre><code>string str =
       "SELECT Name,Members,MaxLvl,Faction,Government,Score FROM dim5orgs where faction =
      'Omni' order by Score DESC";
  
  // Connection string for a typical local MySQL installation
  string cnnString = "Server=xxxxxxxnet;Port=3306;Database=xxx;Uid=xxxxx;Pwd=xxxx";
  
  // Create a connection object and data adapter
  MySqlConnection cnx = new MySqlConnection(cnnString);
  MySqlDataAdapter adapter = new MySqlDataAdapter();
  
  // Create a SQL command object
  string cmdText = str;
  
  MySqlCommand cmd = new MySqlCommand(cmdText, cnx);
  
  // Create a fill a Dataset
  DataSet ds = new DataSet();
  adapter.SelectCommand = cmd;
  adapter.Fill(ds);
  
  StringWriter sw = new StringWriter();
  ds.WriteXml(sw,XmlWriteMode.WriteSchema);
  string result = sw.ToString();
  
  Response.Write(result);
  </code></pre>
  
  <p>Right now I am getting output like:</p>
  
  <pre><code>Punk732220OmniRepublic1644786805740
  
  Paradise754220OmniDepartment1633903815782
  </code></pre>
  
  <p>I would like the output to be in proper XML form somehow using the column names in the dataset. </p>
  
  <p>Like:</p>
  
  <pre><code>&lt;data&gt;
      &lt;name&gt;Punk&lt;/name&gt;
      &lt;members&gt;732&lt;/members&gt;
      &lt;Maxlvl&gt;220&lt;/MaxLvl&gt;...etc 
  &lt;/data&gt;
  </code></pre>
  
  <p>I would like to be in proper XML form, with the XML headers written properly.</p>
  
  <p>Thank you.</p>