Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java XML Parser for huge files

Tags:

java

parsing

xml

I need a xml parser to parse a file that is approximately 1.8 gb.
So the parser should not load all the file to memory.

Any suggestions?

like image 942
mehmet6parmak Avatar asked Oct 19 '10 14:10

mehmet6parmak


People also ask

Which XML parser is fastest Java?

The design is inspired by the design of VTD-XML, the fastest XML parser for Java I have seen, being even faster than the StAX and SAX Java standard XML parsers.

Which parser is best in parsing in large size documents Why?

DOM Parser is faster than SAX Parser. Best for the larger sizes of files.


2 Answers

Aside the recommended SAX parsing, you could use the StAX API (kind of a SAX evolution), included in the JDK (package javax.xml.stream ).

  • StAX Project Home: http://stax.codehaus.org/Home
  • Brief introduction: http://www.xml.com/pub/a/2003/09/17/stax.html
  • Javadoc: https://docs.oracle.com/javase/8/docs/api/javax/xml/stream/package-summary.html
like image 169
Tomas Narros Avatar answered Oct 08 '22 07:10

Tomas Narros


Use a SAX based parser that presents you with the contents of the document in a stream of events.

like image 20
andrewmu Avatar answered Oct 08 '22 08:10

andrewmu