title: Add Attribute to XMLROOT ElementName
body: <p>I have a class with the class attribute : </p>
  
  <pre><code>[XmlRoot(ElementName = "RootXML")]
  public class Apply
  {
      /My Properties
  }
  </code></pre>
  
  <p>now to create an xml from the above class I use below function :</p>
  
  <pre><code>public virtual string RenderXml()
  {
  
      XmlTextWriter writer = null;
      try
      {
          MemoryStream ms = new MemoryStream();
          writer = new XmlTextWriter(ms, Encoding.UTF8);
          writer.Formatting = Formatting.Indented;
          XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
          ns.Add("", "");
          _xmlSerializer.Serialize(writer, this, ns);
          ms.Position = 0;
          using (StreamReader sr = new StreamReader(ms))
          {
              return sr.ReadToEnd();
          }
      }
      finally
      {
          if (writer != null)
              writer.Close();
      }
  }
  </code></pre>
  
  <p>My question is how do i add attributes to "RootXML" and read the value of attribute from config file and from function e.g.</p>
  
  <pre><code>&lt;RootXML attr1="read from config" attr2="read from function" &gt;
      &lt;Property1&gt;value&lt;/Property1&gt;
  &lt;/RootXML&gt;
  </code></pre>