title: Deserializing xml with duplicate entries using xstream
body: <p>I am trying to read in an xml file and store its contents as an object for later use.  I can reproduce a similar object using the toXML() method and providing sample data however when I call fromXML() on the same object I get an error.  The problem is I have multiple instances of fiels.  The xml looks something like this...</p>
  
  <pre><code>&lt;House&gt;   
    &lt;Address&gt;
      &lt;Number&gt;1234&lt;/Number&gt;
      &lt;Street&gt;Sample St.&lt;/Street&gt;
      &lt;City&gt;Sample City&lt;/City&gt;
    &lt;/Address&gt;
    &lt;Resident&gt;
      &lt;Name&gt;Joe&lt;/Name&gt;
      &lt;Age&gt;38&lt;/Age&gt;
      &lt;Profession&gt;
        &lt;Title&gt;Engineer&lt;/Title&gt;
        &lt;Title&gt;Developer&lt;/Title&gt;
      &lt;/Profession&gt;
    &lt;/Resident&gt;
    &lt;Resident&gt;
      &lt;Name&gt;Cathy&lt;/Name&gt;
      &lt;Age&gt;35&lt;/Age&gt;
      &lt;Profession&gt;
        &lt;Title&gt;Engineer&lt;/Title&gt;
        &lt;Title&gt;Developer&lt;/Title&gt;
      &lt;/Profession&gt;
    &lt;/Resident&gt;
  &lt;/House&gt;
  </code></pre>
  
  <p>So in this example there are two residents and they each have two job titles.  I tried defining these tags as arraylists in the constructors' for their respective classes but that didn't seem to work.  This works fine if I only have one instance of  Resident or Title etc.</p>
  
  <p>Here is the Java code (copied from comment below): </p>
  
  <pre><code>XStream xstream = new XStream(new DomDriver()); 
  FileReader fin = new FileReader("path_to_file.xml"); 
  BufferedReader br = new BufferedReader(fin); 
  
  while(br.ready())
  { 
    str += br.readLine() + "\n"; 
  } 
  
  House house = (House)xstream.fromXML(str);
  
  
  import java.util.ArrayList;
  
  
  public class House {
  
  private Address Address;
  private ArrayList&lt;Resident&gt; Resident;
  
  public House(Address address, ArrayList&lt;Resident&gt; resident) {
  
      Address = address;
      Resident = resident;
  }
  
  public Address getAddress() {
      return Address;
  }
  
  public void setAddress(Address address) {
      Address = address;
  }
  
  public ArrayList&lt;Resident&gt; getResident() {
      return Resident;
  }
  
  public void setResident(ArrayList&lt;Resident&gt; resident) {
      Resident = resident;
  }
  
  }
  </code></pre>