title: Spring Boot batch - reading XML input - convert elements to list
body: <p>I have to code a batch service, using Spring Boot, that reads an XML file as input. 
  The structure of the XML input looks like this, and I can't change it :</p>
  
  <pre><code>&lt;root&gt;
      &lt;parent&gt;
          &lt;field1&gt;string&lt;/field1&gt;
          &lt;field2&gt;string&lt;/field2&gt;
          &lt;field3&gt;string&lt;/field2&gt;
          &lt;child&gt;
              &lt;fieldA&gt;string&lt;/fieldA&gt;
              &lt;fieldB&gt;string&lt;/fieldB&gt;
          &lt;/child&gt;
          &lt;child&gt;
              &lt;fieldA&gt;string&lt;/fieldA&gt;
              &lt;fieldB&gt;string&lt;/fieldB&gt;
          &lt;/child&gt;
          &lt;child&gt;
              &lt;fieldA&gt;string&lt;/fieldA&gt;
              &lt;fieldB&gt;string&lt;/fieldB&gt;
          &lt;/child&gt;
      &lt;/parent&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I've created my Java classes :</p>
  
  <pre><code>public class Parent {
      private String field1;
      private String field2;
      private String field3;
      private List&lt;Child&gt; children;
  
      // Getters and setters...
  }
  
  public class Child {
      private String fieldA;
      private String fieldB;
  
      // Getters and setters...
  }
  </code></pre>
  
  <p>And here is my reader in the batch configuration class :</p>
  
  <pre><code>@Bean
  public ItemReader&lt;Object&gt; reader(){
      StaxEventItemReader&lt;Object&gt; reader = new StaxEventItemReader&lt;Object&gt;();
      reader.setResource( new ClassPathResource("input.xml") );
      reader.setFragmentRootElementName("parent");
  
      XStreamMarshaller unmarshaller = new XStreamMarshaller();
      Map&lt;String, Class&gt; aliases = new HashMap&lt;String, Class&gt;();
      aliases.put( "parent", Parent.class );
      aliases.put( "child", Child.class );
      unmarshaller.setAliases(aliases);
  
      reader.setUnmarshaller( unmarshaller );
      return reader;
  }
  </code></pre>
  
  <p>For now I just try to have a correct reading. 
  But when I run the batch, I have an error :</p>
  
  <pre><code>org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field foo.bar.Parent.child
  </code></pre>
  
  <p>I understand this error, but I can't find a way to correct my code.
  I tried to create a fake setter in Parent, adding the child to the children list. But it doesn't seem to work.</p>
  
  <p>Any idea ?</p>