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 How can I split one XML file into Two files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How can I split one XML file into Two files" Watch "How can I split one XML file into Two files" New topic

How can I split one XML file into Two files

BalaiahRaju ChamarthiRaju

Joined: Sep 18, 2007
Posts: 13

I have a task need to split one xml file into two files. this is because of my application supports only 5MB xml to load.. rarely I am getting 10MB files also, such scenarios my application is not able to load the file.

Please give me light on this whether is there any tool or any mechanism to split XML file.

Thanks in Advance
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3274

Well you could write a piece of custom Java which split the file if if gets beyond a certain file size. The tricky part will be deciding where to split that file and whether or not you need to merge that file back together...

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

If you want to extract a subset of the file (a generalization of your "split one file into two files"), a common way to do that is with a SAX filter. Google the expression for examples.
I agree. Here's the link:
subject: How can I split one XML file into Two files
Similar Threads
Question in struts-config.xml
.bat file can execute
splitting the big dom file ??
Spring context xml files
split big DOM xml file ??