title: Java simple XML nested elements deserialize using recursion
body: <p>Is it possible to use recursion with simple framework to deserialize highly nested xml structure?</p>
  <p>Below is sample xml structure that can contain n-levels of Format element lists and sub-list of either inline or element Field:</p>
  <pre><code>&lt;request&gt;
      &lt;Format name=&quot;Transaction&quot; prefix=&quot;BitMap&quot; &gt;
         &lt;Format name=&quot;Bit1&quot; prefix=&quot;Bit1&quot;&gt;
            &lt;Field name=&quot;field1a &quot; length=&quot;3&quot;/&gt;
            &lt;Field name=&quot;field1b&quot; length=&quot;3&quot;/&gt;
         &lt;/Format&gt;
         &lt;Format name=&quot;Bit2&quot; prefix=&quot;Bit2&quot;&gt;
            &lt;Format name=&quot;Bit21&quot; prefix=&quot;Bit21&quot;&gt;
               &lt;Field name=&quot;field21a&quot; length=&quot;3&quot;/&gt;
               &lt;Field name=&quot;field21b&quot; length=&quot;3&quot;/&gt;
            &lt;/Format&gt;
         &lt;/Format&gt;
         &lt;Format name=&quot;Bit3&quot; prefix=&quot;Bit3&quot;&gt;
            &lt;Format name=&quot;Bit31&quot; prefix=&quot;Bit31&quot;&gt;
               &lt;Field name=&quot;field31a&quot; length=&quot;3&quot;&gt;
                  &lt;Mask with=&quot;#&quot;/&gt;
               &lt;/Field&gt;
            &lt;/Format&gt;
            &lt;Format name=&quot;Bit32&quot; prefix=&quot;Bit32&quot;&gt;
               &lt;Format name=&quot;Bit321&quot; prefix=&quot;Bit321&quot;&gt;
                  &lt;Field name=&quot;field321a&quot; length=&quot;3&quot;&gt;
                     &lt;Mask with=&quot;#&quot;/&gt;
                  &lt;/Field&gt;
               &lt;/Format&gt;
            &lt;/Format&gt;
         &lt;/Format&gt;
      &lt;/Format&gt;
  &lt;/request&gt;
  </code></pre>
  <p>Object classes:</p>
  <p>Request</p>
  <pre><code>@Root(strict = false)
  public class Request {
      @ElementList(required = false)
      public ArrayList&lt;Format&gt; Format;
  }
  </code></pre>
  <p>Format</p>
  <pre><code>@Root(strict = false)
  public class Format {
      @ElementList(required = false)
      public ArrayList&lt;Format&gt; Format;
  
      @Attribute(name=&quot;name&quot;, required=false)
      private String name;
  
      @Attribute(name=&quot;prefix&quot;, required=false)
      private String prefix;
  
      @ElementList(entry=&quot;Field&quot;, inline = true, required = false)
      private List&lt;Fields&gt; Field;
  }
  </code></pre>
  <p>Field</p>
  <pre><code>@Root(name=&quot;Field&quot;,strict = false)
  public class Fields {
      @Element(name=&quot;Field&quot;, required=false)
      private String Field;
  
      @Attribute(name=&quot;name&quot;, required=false)
      private String name;
  
      @Attribute(name=&quot;length&quot;, required=false)
      private String length;
  
      @Element(required = false)
      private Mask Mask;
  
      static class Mask{
          @Attribute(required = false)
          private String with;
      }
  }
  </code></pre>
  <p>Without converter annotation, XML can be deserialized up to 2nd level only so I began looking at recursion.</p>
  <p>I'm trying to do it via converter class but during traversal of field nodes, node.getnext() seems not able to see the next inline Field within the same parent node. I can only get the first inline Field</p>
  <p>2 weeks into this and I'm out of ideas.
  Any help will be greatly appreciate by this Java newbie.</p>