VTD-XML: The Future of XML Processing

SourceForge.net Logo

Sourceforge Home

Mailing Lists





Process Huge XML Documents (Bigger than 2GB)

(For more code samples, visit Official VTD-XML Blog)

(Separate code-only VTD-XML tutorials are available in C, C++, Java and C#)

This example shows you how to use extended VTD-XML and XPath to process XML documents bigger than 2GB. To use it, your application needs to include com.ximpleware.extended and be run within a 64-bit JVM. The code can be downloaded here:

 * This is a demonstration of how to use the extended VTD parser
 * to process huge XML files.

import com.ximpleware.extended.*;

class mem_mapped_read {

public static void main(String[] s) throws Exception{




The starting point is to instantiate an instance of VTDGenHuge, then you need to call parseFile(). By default, parseFile() loads the document in memory. If you want to invoke memory mapping (on demand loading), you have to set the mode to VTDGenHuge.MEM_MAPPED. After parsing, you need to get an instance of VTDNavHuge (very similar to VTDNav).

VTDGenHuge vgh = new VTDGenHuge();
if (vgh.parseFile("test.xml",true,VTDGenHuge.MEM_MAPPED)){
        VTDNavHuge vn = vgh.getNav();


You can then instantiate an instance of AutoPilotHuge, which is virtually identical to AutoPilot in the standard version.

The code using the XPath feature of VTD-XML version 1.0 is a little different. The XPath expression is compiled by calling "selectXPath(...)" of AutoPilot. Calling evalXPath(...) moves the cursor to the selected nodes in the node set. Additional exceptions are com.ximpleware.xpath.XPathEvalException and com.ximpleware.xpath.XPathParseException.


AutoPilotHuge aph = new AutoPilotHuge(vnh);
int i = 0;
while ((i=aph.evalXPath())!=-1){
          System.out.println(" element name is "+vnh.toString(i));

Notice that in exceptions in extended VTD-XML have similar names comparing with their counter parts in regular VTD-XML. They are:

VTD in 30 seconds

VTD+XML Format

User's Guide

Developer's Guide

VTD: A Technical Perspective

Code Samples

  RSS Reader in Java

  RSS Reader in C

  SOAP in Java

  SOAP in C

  BioInfo in Java

  BioInfo in C

  Modify XML In Java

  Modify XML In C


  Edit XML

  Index Creation and Loading

  Process Huge XML Files (>2G)


Getting Involved

Articles and Presentations