title: Adding Subroot elements in XML
body: <p>I'm making an XML Document which contains subroot nodes. I'm using <code>XmlDocument</code> and adding the child nodes.</p>
  
  <p>This is my code:</p>
  
  <pre><code>  XmlDocument doc = new XmlDocument();
    XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
    doc.AppendChild(dec);
  
    XmlElement root = doc.CreateElement("LICENSE");
  
    if (strGInfo == "")
    {
      strGInfo = "N/A";
    }
  
    XmlElement ginfo = doc.CreateElement("GENERAL_INFO");
    ginfo.InnerText = strGInfo;
    root.AppendChild(ginfo);
  
  
    if (strLNo == "")
    {
       strLNo = "N/A";
    }
  
    XmlElement subroot = doc.CreateElement("LICENSE_INFO");
    //XmlElement root1 = doc.CreateElement("LICENSE_INFO");
  
    XmlElement lno = doc.CreateElement("LICENCE_NO");
    lno.InnerText = txtLNo.Text;
    subroot.AppendChild(lno);
  
    if (strUID == "")
    {
       strUID = "N/A";
    }
  
    XmlElement uid = doc.CreateElement("USER_ID");
    uid.InnerText = txtUID.Text;
    subroot.AppendChild(uid);
  
    if (strOrg == "")
    {
      strOrg = "N/A";
    }
  
    XmlElement org = doc.CreateElement("ORGANIZATION");
    org.InnerText = txtOrg.Text;
    subroot.AppendChild(org);
  
              if (strUName == "")
              {
                  strUName = "N/A";
              }
  
              XmlElement uname = doc.CreateElement("USER_NAME");
              uname.InnerText = txtUName.Text;
              subroot.AppendChild(uname);
  
              if (strSType == "")
              {
                  strSType = "N/A";
              }
  
              XmlElement stype = doc.CreateElement("SOLUTION_TYPE");
              stype.InnerText = txtSType.Text;
              subroot.AppendChild(stype);
  
              if (strVer == "")
              {
                  strVer = "N/A";
              }
  
              XmlElement ver = doc.CreateElement("VERSION");
              ver.InnerText = txtVer.Text;
              subroot.AppendChild(ver);
  
              XmlElement ltype = doc.CreateElement("LICENCE_TYPE");
              ltype.InnerText = drpLType.SelectedItem.Text;
              subroot.AppendChild(ltype);
  
              if (strMeapSupp == "")
              {
                  strMeapSupp = "N/A";
              }
  
              XmlElement meapsupp = doc.CreateElement("MEAP_SUPPORT");
              meapsupp.InnerText = rdoMeapSupport.Text;
              subroot.AppendChild(meapsupp);
  
              XmlElement LicFrom = doc.CreateElement("LICENCE_FROM");
              LicFrom.InnerText = lblLFrom.Text;
              subroot.AppendChild(LicFrom);
  
              XmlElement LicTo = doc.CreateElement("LICENCE_TO");
              LicTo.InnerText = lblLTo.Text;
              subroot.AppendChild(LicTo);
  
              XmlElement suppfrom = doc.CreateElement("SUPPORT_FROM");
              suppfrom.InnerText = lblSuppFrom.Text;
              subroot.AppendChild(suppfrom);
  
              XmlElement suppto = doc.CreateElement("SUPPORT_TO");
              suppto.InnerText = lblSuppTo.Text;
              subroot.AppendChild(suppto);
  
              doc.AppendChild(subroot);
  
              XmlElement subroot2 = doc.CreateElement("LICENCE_CONSTRAINT");
  
              if (strMaxUsr == "")
              {
                  strMaxUsr = "N/A";
              }
  
              XmlElement maxusr = doc.CreateElement("MAX_USER");
              maxusr.InnerText = txtMaxUsr.Text;
              subroot2.AppendChild(maxusr);
  
              if (strMaxMach == "")
              {
                  strMaxMach = "N/A";
              }
  
              XmlElement maxmach = doc.CreateElement("MAX_MACHINE");
              maxmach.InnerText = txtMaxMach.Text;
              subroot2.AppendChild(maxmach);
  
              if (strMachIP == "")
              {
                  strMachIP = "N/A";
              }
  
              doc.AppendChild(subroot2);
  
              XmlElement subroot3 = doc.CreateElement("MACHINE_INFO");
  
              XmlElement machip = doc.CreateElement("MACHINE_IP");
              machip.InnerText = txtMachIP.Text;
              subroot3.AppendChild(machip);
  
              if (strMachMac == "")
              {
                  strMachMac = "N/A";
              }
  
              XmlElement machmac = doc.CreateElement("MACHINE_MAC");
              machmac.InnerText = txtMachMac.Text;
              subroot3.AppendChild(machmac);
  
              doc.AppendChild(subroot3);
  
              XmlElement subroot4 = doc.CreateElement("LICENCE_SIGNATURE");
  
              XmlElement UqID = doc.CreateElement("UNIQUE_ID");
              UqID.InnerText = txtUqID.Text;
              subroot4.AppendChild(UqID);
  
              doc.AppendChild(subroot4);
  
              doc.Save(@"D:\New.xml");
  </code></pre>
  
  <p>My XML Document should look something like this:</p>
  
  <pre><code>-&lt;LICENSE&gt;
    &lt;GENERAL_INFO&gt; &lt;/GENERAL INFO&gt;
  -&lt;LICENSE_INFO&gt;
     &lt;LICENSE_NO&gt; &lt;/LICENSE_NO&gt;
     &lt;USER_ID&gt; &lt;/USER_ID&gt; //etc
  -&lt;LICENCE_CONSTRAINT&gt;
     &lt;MAX_USER&gt; &lt;/MAX_USER&gt; 
     &lt;MAX_MACHINE&gt; &lt;/MAX_MACHINE&gt; 
    &lt;/LICENCE_CONSTRAINT&gt;
  -&lt;MACHINE_INFO&gt;
    &lt;MACHINE_IP&gt; &lt;/MACHINE_IP&gt; 
    &lt;MACHINE_MAC&gt; &lt;/MACHINE_MAC&gt; 
   &lt;/MACHINE_INFO&gt;
  &lt;/LICENSE_INFO&gt;
  </code></pre>
  
  <p>Where am I going wrong?</p>