title: How to achieve the required XML serialisation?
body: <p>The following class:</p>
  
  <pre><code>    public class CodelistFilters
      {
          [System.Xml.Serialization.XmlArray]
          public List&lt;CodelistFilterAndElement&gt; AndGroup;
  
      }
      public class CodelistFilterAndElement
      {
          [System.Xml.Serialization.XmlArray]
          public List&lt;CodelistFilterOrElement&gt; OrGroup;
  
          [System.Xml.Serialization.XmlAttribute]
          public string Relationship { get { return "And"; } }
      }
  
      public class CodelistFilterOrElement
      {
          [System.Xml.Serialization.XmlElement]
          public List&lt;CodelistFilter&gt; CodelistFilters;
  
          [System.Xml.Serialization.XmlAttribute]
          public string Relationship { get { return "Or"; } }
      }
  
      public class CodelistFilter
      {
          [System.Xml.Serialization.XmlAttribute]
          public string Name { get; set; }
  
          [System.Xml.Serialization.XmlAttribute]
          public string Value1 { get; set; }
  
          [System.Xml.Serialization.XmlAttribute]
          public string Value2 { get; set; }
  
      }
  </code></pre>
  
  <p>gets serialised as</p>
  
  <pre><code>&lt;CodelistFilters xmlns:xsi="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;AndGroup&gt;
      &lt;CodelistFilterAndElement&gt;
          &lt;OrGroup&gt;
              &lt;CodelistFilterOrElement&gt;
                  &lt;CodelistFilters&gt;
                      &lt;CodelistFilter Name="Description" Value1="test" /&gt;
                  &lt;/CodelistFilters&gt;
              &lt;/CodelistFilterOrElement&gt;
          &lt;/OrGroup&gt;
      &lt;/CodelistFilterAndElement&gt;
  &lt;/AndGroup&gt;
  </code></pre>
  
  <p></p>
  
  <p>Which I sort of understand. However, what I'm trying to achieve this:</p>
  
  <pre><code>&lt;CodelistFilters xmlns:xsi="http://www.w3.org/2001/XMLSchema"&gt;
  &lt;Group Relationship="And"&gt; 
      &lt;Group Relationship="Or"&gt;
          &lt;CodelistFilters Name="Description" Value1="test" /&gt;
      &lt;/Group&gt;
  &lt;/Group&gt;
  </code></pre>
  
  <p></p>
  
  <p>How should I structure my C# class to achieve this? I've tried messing around with XmlAttributes and nested Lists but just end up with different versions of "wrong".</p>