Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If this in Java you could try using <a href="http://dom4j.sourceforge.net/dom4j-1.6.1/apidocs/" rel="nofollow">dom4j</a>. This has a nice way of reading the xml using the xpathExpression.</p> <p>Additionally dom4j provides an event based model for processing XML documents. Using this event based model allows us to prune the XML tree when parts of the document have been successfully processed avoiding having to keep the entire document in memory.</p> <p>If you need to process a very large XML file that is generated externally by some database process and looks something like the following (where N is a very large number). </p> <pre><code>&lt;ROWSET&gt; &lt;ROW id="1"&gt; ... &lt;/ROW&gt; &lt;ROW id="2"&gt; ... &lt;/ROW&gt; ... &lt;ROW id="N"&gt; ... &lt;/ROW&gt; &lt;/ROWSET&gt; </code></pre> <p>So to process each <code>&lt;ROW&gt;</code> individually you can do the following.</p> <pre><code>// enable pruning mode to call me back as each ROW is complete SAXReader reader = new SAXReader(); reader.addHandler( "/ROWSET/ROW", new ElementHandler() { public void onStart(ElementPath path) { // do nothing here... } public void onEnd(ElementPath path) { // process a ROW element Element row = path.getCurrent(); Element rowSet = row.getParent(); Document document = row.getDocument(); ... // prune the tree row.detach(); } } ); Document document = reader.read(url); // The document will now be complete but all the ROW elements // will have been pruned. // We may want to do some final processing now ... </code></pre> <p>Please see <a href="http://dom4j.sourceforge.net/dom4j-1.6.1/faq.html#large-doc" rel="nofollow">How dom4j handle very large XML documents?</a> to understand how it works. </p> <hr> <p>Moreover dom4j works with any SAX parser via JAXP. For more details see <a href="http://dom4j.sourceforge.net/dom4j-1.6.1/faq.html#what-parser" rel="nofollow">What XML parser does dom4j use?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload