title: Allow duplicate node name in XML serialization using C#
body: <p>I'm trying to serialize an object that have a duplicate node name using C#, the reason what i need to do this is because i'm building a library that use a third party API.</p>
  
  <p>The request i need to build look like this.</p>
  
  <pre><code>&lt;DATASET&gt;
     &lt;SITE_ID&gt;123&lt;/SITE_ID&gt;
     &lt;DATA type=“name”&gt;Secondary List&lt;/DATA&gt;
     &lt;DATA type="extra" id="CLICKTHRU_URL"&gt;http://my.domain.com/&lt;/DATA&gt;
     &lt;DATA type="extra" id="REPLY_FORWARD_EMAIL"&gt;support@my.domain.com&lt;/DATA&gt;
     &lt;DATA type="extra" id="REPLY_FROM_EMAIL"&gt;forward@my.domain.com&lt;/DATA&gt;
     &lt;DATA type="extra" id="REPLY_FROM_NAME"&gt;8@yahoo.com&lt;/DATA&gt;
     &lt;DATA type="extra" id="REPLY_FORWARD_SUBJECT"&gt;Customer Replies&lt;/DATA&gt;
     &lt;DATA type="extra" id="HANDLE_UNSUBSCRIBE"&gt;&lt;/DATA&gt;
     &lt;DATA type="extra" id="HANDLE_AUTOREPLY"&gt;&lt;/DATA&gt;
     &lt;DATA type="extra" id="FOOTER_TEXT"&gt;Confidentiality agreement…&lt;/DATA&gt;
     &lt;DATA type="extra" id="FOOTER_HTML"&gt; Confidentiality agreement…&lt;/DATA&gt;
  &lt;/DATASET&gt;
  </code></pre>
  
  <p>My approach is create a class that represent the request and use the XML serialization attributes, the class look like this:</p>
  
  <pre><code>[XmlRoot("DataSet")]
  public class AddListCallHolder : BaseCallHolder
  {
      private BaseAttributeHolder _name = new BaseAttributeHolder(type: "");
  
      [XmlElement("DATA")]
      public BaseAttributeHolder Name
      {
          get { return _name; }
          set { _name = value; }
      }
  
      private BaseAttributeHolder _clickthruUrl = new BaseAttributeHolder(id: "CLICKTHRU_URL");
  
      [XmlElement("DATA")]
      public BaseAttributeHolder CLICKTHRU_URL
      {
          get { return _clickthruUrl; }
          set { _clickthruUrl = value; }
      }
  }
  </code></pre>
  
  <p>The base class of the attribute is:</p>
  
  <pre><code>public class BaseAttributeHolder
  {
      [XmlAttribute("type")]
      public string Type { get; set; }
  
      [XmlAttribute("id")]
      public string Id { get; set; }
  
      [XmlText]
      public string Value { get; set; }
  
      public BaseAttributeHolder(string value, string id, string type = "extra")
      {
          Type = type;
          Value = value;
          Id = id;
      }
  
      public BaseAttributeHolder(string id, string type = "extra")
      {
          Type = type;
          Id = id;
      }
  
      public BaseAttributeHolder(string type = "extra")
      {
          Type = type;
      }
  
      public BaseAttributeHolder()
      {
  
      }
  }
  </code></pre>
  
  <p>When i try to serialize and object i getting this error:</p>
  
  <blockquote>
    <p>The XML element 'DATA' from namespace '' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.</p>
  </blockquote>
  
  <p>Is there any work around to serialize this object or get the the structure of the request.</p>