DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Jimmy has posted 14 posts at DZone. View Full User Profile

How To Process Huge XML Documents Using Extended VTD-XML?

  • submit to reddit
        // description of your code here
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.
 * This is a demonstration of how to use the extended VTD parser
 * to process large XML file. You need 64-bit JVM to take full 
 * advantage of extended VTD.
import com.ximpleware.extended.*;
public class mem_mapped_read {
	public static void main(String[] s) throws Exception{
	    VTDGenHuge vg = new VTDGenHuge();
	    if (vg.parseFile("test.xml",true,VTDGenHuge.MEM_MAPPED)){
	        VTDNavHuge vnh = vg.getNav();
		AutoPilotHuge aph = new AutoPilotHuge(vnh);
		int i = 0;
		while ((i=aph.evalXPath())!=-1){
			System.out.println(" element name is "+vnh.toString(i));