title: Reading Huge XML File using StAX and XPath
body: <p>The input file contains thousands of transactions in XML format which is around 10GB of size. The requirement is to pick each transaction XML based on the user input and send it to processing system.</p>
  
  <p><strong>The sample content of the file</strong></p>
  
  <pre><code>&lt;transactions&gt;
      &lt;txn id="1"&gt;
        &lt;name&gt; product 1&lt;/name&gt;
        &lt;price&gt;29.99&lt;/price&gt;
      &lt;/txn&gt;
  
      &lt;txn id="2"&gt;
        &lt;name&gt; product 2&lt;/name&gt;
        &lt;price&gt;59.59&lt;/price&gt;
      &lt;/txn&gt;
  &lt;/transactions&gt;
  </code></pre>
  
  <p>The (technical)user is expected to give the input tag name like <code>&lt;txn&gt;</code>. </p>
  
  <p>We would like to provide this solution to be more generic. The file content might be different and users can give a XPath expression like "<code>//transactions/txn</code>" to pick individual transactions.</p>
  
  <p><strong>There are few technical things we have to consider here</strong></p>
  
  <ul>
  <li>The file can be in a shared location or FTP </li>
  <li>Since the file size is huge, we can't load the entire file in JVM</li>
  </ul>
  
  <p><strong>Can we use StAX parser for this scenario? It has to take XPath expression as a input and pick/select transaction XML.</strong> </p>
  
  <p>Looking for suggestions. Thanks in advance.</p>