title: Java/XML: Good "Stream-based" Alternative to JAXB?
body: <p>JAXB makes working with XML so much easier, but I have currently a big problem, that the documents I have to process are too large for an in memory unmarshalling that JAXB does. The data can be up to 4GB per document. </p>
  
  <p>The datastructure I will have to process is very simple and flat: With a root element and millions of “elements”…</p>
  
  <pre><code>&lt;root&gt;
  &lt;element&gt;
  &lt;sub&gt;foo&lt;/sub&gt;
  &lt;/element&gt;
  &lt;element&gt;
  &lt;sub&gt;foo&lt;/sub&gt;
  &lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>May questions are:</p>
  
  <ol>
  <li><p>Does JAXB maybe somehow support unmarshalling in a “streambased” way, that does not require to build the whole objecttree in memory but rather gives me some kind of “Iterator” to the elements, element by element? (Maybe I just missed that somehow…)</p></li>
  <li><p>If not what are your proposals for an good alternative with a 
  a.  “flat learningcurve, ideally very similar to JAXB 
  b.  AND VERY IMPORTANT: Ideally with the possibility / tool for the generation of the unarshaller code from an XSD file OR annotated Java Class</p></li>
  </ol>
  
  <p>3.(I have searched SO and those to library that ended up on my “watchlist” (without comparing them closer) were Apache XML Beans and Xstream… 
  What other libraries are maybe even better for the purpose and what are the disadvantages, adavangaes…</p>
  
  <p>Thank you very much!!!
  Jan</p>