title: After importing DataSet from XML, new rows are not nested properly
body: <p>I'm using <code>DataSet.ReadXml()</code> to import an XML file into a new DataSet. Then I'm adding a new row to one of the tables inside the DataSet, and then I want to export that DataSet to XML again. The problem is that the new row is not nested properly and just gets appended to the end of the XML file.</p>
  
  <p>Here is the program:</p>
  
  <pre class="lang-cs prettyprint-override"><code>    using System;
      using System.Data;
      using System.IO;
      using System.Xml;
  
      public class Program
      {
          public static void Main()
          {
              string xml = @"&lt;?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?&gt;
      &lt;DATAPACKET Version=""2.0""&gt;
          &lt;METADATA&gt;
              &lt;FIELDS&gt;
                  &lt;FIELD attrname=""CompanyID"" fieldtype=""string"" WIDTH=""10""/&gt;
                  &lt;FIELD attrname=""Description"" fieldtype=""string"" WIDTH=""40""/&gt;
              &lt;/FIELDS&gt;
              &lt;PARAMS/&gt;
          &lt;/METADATA&gt;
          &lt;ROWDATA&gt;
              &lt;ROW CompanyID=""CC"" Description=""Contoso""/&gt;
          &lt;/ROWDATA&gt;
      &lt;/DATAPACKET&gt;
      ";
              XmlReader reader = XmlReader.Create(new StringReader(xml));
              DataSet dataSet = new DataSet();
              dataSet.ReadXml(reader, XmlReadMode.InferTypedSchema);
              var rowTable = dataSet.Tables["ROW"];
              var newRow = rowTable.NewRow();
              newRow["CompanyID"] = "APPL";
              newRow["Description"] = "Apple";
              rowTable.Rows.Add(newRow);
              Console.WriteLine(dataSet.GetXml());
          }
      }
  </code></pre>
  
  <p>And here is the output:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;DATAPACKET Version="2.0"&gt;
        &lt;METADATA&gt;
          &lt;PARAMS /&gt;
          &lt;FIELDS&gt;
            &lt;FIELD attrname="CompanyID" fieldtype="string" WIDTH="10" /&gt;
            &lt;FIELD attrname="Description" fieldtype="string" WIDTH="40" /&gt;
          &lt;/FIELDS&gt;
        &lt;/METADATA&gt;
        &lt;ROWDATA&gt;
          &lt;ROW CompanyID="CC" Description="Contoso" /&gt;
        &lt;/ROWDATA&gt;
      &lt;/DATAPACKET&gt;
      &lt;ROW CompanyID="APPL" Description="Apple" /&gt;
  </code></pre>
  
  <p>What I want is for the new row to be nested with the other rows from that table like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;DATAPACKET Version="2.0"&gt;
        &lt;METADATA&gt;
          &lt;PARAMS /&gt;
          &lt;FIELDS&gt;
            &lt;FIELD attrname="CompanyID" fieldtype="string" WIDTH="10" /&gt;
            &lt;FIELD attrname="Description" fieldtype="string" WIDTH="40" /&gt;
          &lt;/FIELDS&gt;
        &lt;/METADATA&gt;
        &lt;ROWDATA&gt;
          &lt;ROW CompanyID="CC" Description="Contoso" /&gt;
          &lt;ROW CompanyID="APPL" Description="Apple" /&gt;
        &lt;/ROWDATA&gt;
      &lt;/DATAPACKET&gt;
  </code></pre>
  
  <p>What am I doing wrong? 
  How do I get well formed XML out of <code>DataSet.GetXml()</code> ?</p>
  
  <p><a href="https://dotnetfiddle.net/Widget/FCFQ9e" rel="nofollow noreferrer">Here is the program running over at dotnetfiddle</a></p>