title: Java Split XML file
body: <p>How can i split an long XML-file into pieces with each a predefined different name?</p>
  
  <p>Example this is my XML file pasted in one long XML, generated for testing.
  Now i have to split on envelope, each a new file.</p>
  
  <pre><code>&lt;envelope&gt;
   &lt;tag1&gt;1&lt;/tag1&gt;
   &lt;tag2&gt;2&lt;/tag2&gt;
   &lt;tag3&gt;3&lt;/tag3&gt;
  &lt;/envelope&gt;
  &lt;envelope&gt;
   &lt;tag1&gt;1&lt;/tag1&gt;
   &lt;tag2&gt;2&lt;/tag2&gt;
   &lt;tag3&gt;3&lt;/tag3&gt;
  &lt;/envelope&gt;
  &lt;envelope&gt;
   &lt;tag1&gt;1&lt;/tag1&gt;
   &lt;tag2&gt;2&lt;/tag2&gt;
   &lt;tag3&gt;3&lt;/tag3&gt;
  &lt;/envelope&gt;
  </code></pre>
  
  <p>I have already work with splits before just not like this where there is no begin and end tag for the entire xml. </p>