www.webdeveloper.com
Results 1 to 2 of 2

Thread: Splitting XML Documents Using Java

  1. #1
    Join Date
    Sep 2008
    Posts
    1

    Question Splitting XML Documents Using Java

    Hi,

    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.

  2. #2
    Join Date
    Sep 2008
    Posts
    5
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles