title: Creating XML structure using xml attributes
body: <p>I am trying to solve a puzzle with xml attributes. The problem is that we already have widely used file with this structure, from which I can't deviate</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;CONFIGS&gt;
    &lt;CONFIG&gt;
      &lt;NAME&gt;c1&lt;/NAME&gt;
      &lt;DB&gt;
        &lt;VAL1&gt;v1&lt;/VAL1&gt;
        &lt;VAL2&gt;v2&lt;/VAL2&gt;
        &lt;VAL3&gt;v3&lt;/VAL3&gt;
      &lt;/DB&gt;
    &lt;/CONFIG&gt;
    &lt;CONFIG&gt;
      &lt;NAME&gt;c2&lt;/NAME&gt;
      &lt;DB&gt;
        &lt;VAL1&gt;v1&lt;/VAL1&gt;
        &lt;VAL2&gt;v2&lt;/VAL2&gt;
        &lt;VAL3&gt;v3&lt;/VAL3&gt;
      &lt;/DB&gt;
    &lt;/CONFIG&gt;
  &lt;/CONFIGS&gt;
  </code></pre>
  
  <p>I've created this c# code</p>
  
  <pre class="lang-cs prettyprint-override"><code>// master class
  [XmlRoot(ElementName = "CONFIGS")]
  public class MyConfigs
  {
  
      [XmlArrayItem(ElementName = "CONFIG", Type = typeof(MyConfigSchema))]
      public MyConfigSchema[] Schemas { get; set; }
  }
  
  // I should have array of these
  public class MyConfigSchema
  {
  
      [XmlElement(DataType = "string", ElementName = "NAME")]
      public string Name { get; set; }
  
      [XmlElement(ElementName = "DB", Type = typeof(Db))]
      public Db Config { get; set; }
  
      // this element is single and has subelements
      public class Db
      {
  
          [XmlElement(DataType = "string", ElementName = "VAL1")]
          public string Val1 { get; set; }
  
          [XmlElement(DataType = "int", ElementName = "VAL2")]
          public int Val2 { get; set; }
  
          [XmlElement(DataType = "string", ElementName = "VAL3")]
          public string Val3 { get; set; }
  
      }
  }
  
  // Writing 
  using (var writer = new FileStream(testfile, FileMode.Create))
          {
              var ser = new XmlSerializer(typeof(MyConfigs));
              ser.Serialize(writer, confFileObj);
              writer.Close();
          }
  </code></pre>
  
  <p>Here is my issue - it writes the following output, which is almost what I need but in there it writes <code>&lt;Schemas&gt;. . . &lt;/Schemas&gt;</code> that I can't have.</p>
  
  <blockquote>
    <p><code>&lt;CONFIGS&gt;
        --&lt;Schemas&gt;--
          &lt;CONFIG&gt;
            &lt;NAME&gt;c1&lt;/NAME&gt;
            &lt;DB&gt;
              &lt;VAL1&gt;v1&lt;/VAL1&gt;
              &lt;VAL2&gt;v2&lt;/VAL2&gt;
              &lt;VAL3&gt;v3&lt;/VAL3&gt;
            &lt;/DB&gt;
          &lt;/CONFIG&gt;
          &lt;CONFIG&gt;
            &lt;NAME&gt;c2&lt;/NAME&gt;
            &lt;DB&gt;
              &lt;VAL1&gt;v1&lt;/VAL1&gt;
              &lt;VAL2&gt;v2&lt;/VAL2&gt;
              &lt;VAL3&gt;v3&lt;/VAL3&gt;
            &lt;/DB&gt;
          &lt;/CONFIG&gt;
        --&lt;/Schemas&gt;--
      &lt;/CONFIGS&gt;</code></p>
  </blockquote>
  
  <p>Is there a way of get rid of <code>&lt;Schemas&gt;. . . &lt;/Schemas&gt;</code>?</p>