title: Splitting a big XML file into smaller ones
body: <p>I'm currently working on a project that requires me to split an XML. For example here is a sample:</p>
  
  <pre><code>&lt;Lakes&gt;
    &lt;Lake&gt;
      &lt;id&gt;1&lt;/id&gt;
      &lt;Name&gt;Caspian&lt;/Name&gt;
      &lt;Type&gt;Natyral&lt;/Type&gt;
    &lt;/Lake&gt;
    &lt;Lake&gt;
      &lt;id&gt;2&lt;/id&gt;
      &lt;Name&gt;Moreo&lt;/Name&gt;
      &lt;Type&gt;Glacial&lt;/Type&gt;
    &lt;/Lake&gt;
    &lt;Lake&gt;
      &lt;id&gt;3&lt;/id&gt;
      &lt;Name&gt;Sina&lt;/Name&gt;
      &lt;Type&gt;Artificial&lt;/Type&gt;
    &lt;/Lake&gt;
  &lt;/Lakes&gt;
  </code></pre>
  
  <p>Now in my java code ideally what would happen is it will split the XML into 3 small ones for this example and send each of them out using a messenger service. The code for the messenger service is not important. I have that done already.</p>
  
  <p>So for example the code would run, split the first part into this:</p>
  
  <pre><code>&lt;Lakes&gt;
    &lt;Lake&gt;
      &lt;id&gt;1&lt;/id&gt;
      &lt;Name&gt;Caspian&lt;/Name&gt;
      &lt;Type&gt;Natyral&lt;/Type&gt;
    &lt;/Lake&gt;
  &lt;/Lakes&gt;
  </code></pre>
  
  <p>and then the java code would send this out in a message. It would then move on to the next part, send that out etc etc until it reaches the end of the big XML. This can be done through an XSLT or through java it doesn't matter. Any ideas?</p>
  
  <p>To make it clear, I pretty much know how to break up a file using XSLT but I don't know how to break it up and send each part individually one at a time. I also don't want to store anything locally so they would ideally all get transferred into strings and sent out.</p>