File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Parsing huge XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing huge XML file" Watch "Parsing huge XML file" New topic

Parsing huge XML file

Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Hi All
I have a requirement to read ,write and modify, huge XML documents whose size may be several MBs or a couple of GBs too. Is there an efficient way of doing this. I think placing whole of it 'in memory' like in JDOM document is surely going to lead to 'Out of memory'. Any help is greatly appreciated.
Satya Deep

Thanks and Regards
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
With huge files, as you said, the DOM approach will not fit in memory so you are looking at using an event processing style like SAX.

Depending on your exact problem you may find the ServingXML toolkit will help.

The SmallX toolkit is another possibility.

By all means read Harold's free online chapter on SAX filters.

Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Thanks Bill!
I agree. Here's the link:
subject: Parsing huge XML file
It's not a secret anymore!