Over a million developers have joined DZone.

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

·
// 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);
		aph.selectXPath("//*");
		int i = 0;
		while ((i=aph.evalXPath())!=-1){
			System.out.println(" element name is "+vnh.toString(i));
		}
	        
	    }
	}
}

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}