Splitting XML Documents Using Java
Is their any standard methods or procedures are available for Creating different Child XML Documents from Parent XML Document in Java.
Please let me know any samples is their.
No simple method call I know of.
Assuming you're going to use JAX-P as its part of the Java libraries, you have two choices. SAX or DOM.
DOM is an 'in memory' model of your XML document. That it , it loads the document into DOM Document.
You can then do as you want with it, so you could., for instance, split it into 'DocumentFragments' by moving nodes (and their descendants) out of the Document, into new Fragments. These Fragments can then be serialised as stand alone XML documents.
SAX is a streaming interface. Far simpler and a shed load faster.
With this you are notified of Elements as they are parsed, as method calls.
For your requirement, I'd SAX parse your parent document, and write out to various streams to get your child documents.
Switch streams when the relevant child elements are parsed.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)