title: Serialize same object type at multiple levels
body: <p>I am looking for an XML Structure like this -</p>
  
  <pre><code>&lt;Directory id="ID1" Name="N1"&gt;
     &lt;Directory id="ID2" Name="N2"&gt;
        &lt;Directory id="ID3" Name="N3"&gt;
           &lt;Directory id="ID4" Name="N4"/&gt;
        &lt;/Directory&gt;
     &lt;/Directory&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>I wrote a class -</p>
  
  <pre><code>namespace Application1
  {
     public class Directory
     {
        [XmlAttribute]
        public string Id { get; set; }
        [XmlAttribute]
        public string Name { get; set; }
        [XmlElement("Directory ")]
        public Dir[] Directory { get; set; }
     }
  }
  </code></pre>
  
  <p>But this does not generate the XML in the form I wanted. </p>