title: Traverse a XML file in Android
body: <p>I'm developing an app in Android and I need to traverse a xml file.</p>
  
  <p>I need to traverse a xml - backwards and forward from a given position. It means i start to parse the file, but at each instant i can stop and go backwards or continue.</p>
  
  <p>I was thinking in using DOM, with its for cycle i could control it and do what i wanted. But the xml file that i want to parse has at least 8 Mb and since DOM is very memory intensive, don't seem to be a good solution.</p>
  
  <p>A solution to this problem was not to load the whole document for parsing. Like to split the document in several parts and only load one part to memory and parse. When i come to the end of this part, i load another. The same when i want to rewind.</p>
  
  <p>My question is, how can i achieve to split the file in several pieces. Since it is a xml file and the childs don't have all the same size ?</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;root&gt;
     &lt;child time="A"&gt;
       &lt;sub1&gt;1&lt;/sub1&gt;
       &lt;sub2&gt;2&lt;/sub2&gt;
     &lt;/child&gt;
  
     &lt;child time="B"&gt;
       &lt;sub1&gt;3&lt;/sub1&gt;
     &lt;/child&gt;
  
     &lt;child time="C"&gt;
       &lt;sub2&gt;4&lt;/sub2&gt;
     &lt;/child&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>As you can see, their childs have different sizes and i don't know how I can split a file like this in an efficient way in several parts.</p>
  
  <p>Can anyone give me a clue ?</p>
  
  <p>Best regards.</p>