2

I am trying to parse xml using JDOM. The problem is i want split a huge xml file into smaller files. The huge xml contains many <page></page>. I want to treat each <page></page> as a page. I am not able to find a function which could just copy the everything from <page>,</page> to different files.

Out0.xml
<page>
</page>

out1.xml
<page>
</page>

Brute options are to go through each tag copying every data, but that is boring. Is there a way I could copy all bytes within <page>,<page> different pages? Is there a function similar to VTD-xml::getXML().getBytes();

1 Answer 1

3

This sounds like a task for XSLT or StAX more than JDOM. If the original file is truly huge, JDOM's actually very memory intensive and that route likely won't work.

Sign up to request clarification or add additional context in comments.

2 Comments

I had considered XSLT and StAX but just wanted to be consistent with my code where i have used JDOM for parsing. I will try using XSLT/Stax. But, if there is a better option do let me know ?
I guess in XML parsing APIs, there are a lot of tradeoffs on ease of use vs. speed and memory consumption, and unfortunately, you might need to be flexible sometimes if the situation warrants it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.