1

Is it possible to "split" XML tree to more subsets and then use different parsers for parsing?

DOM parser puts whole document to memory and then analyze it, so i guess there is no point to use that for reading subsets. Could i use Push and pull parsers(SAX and StAX) for parsing subsets?

thanks

ivanz
  • 775
  • 2
  • 11
  • 31
  • The following may help: http://stackoverflow.com/questions/5169978/split-1gb-xml-file-using-java/5170415#5170415 – bdoughan Jun 25 '13 at 11:23
  • 1
    I have 3GB XML file on which i would like to use DOM(on one small part of XML), then SAX and StAX. Best thing for DOM would be to create new XML file with StAX and then read that new XML with DOM. I am not searching for complete code, i am not looking for code what so ever, more like discussion. Thanks – ivanz Jun 25 '13 at 11:26
  • @BlaiseDoughan: thanks. Actually my question is bad... i am looking for something like: When is it good to combine StAX and SAX for reading XML files – ivanz Jun 25 '13 at 11:29
  • I have added an answer: http://stackoverflow.com/a/17296182/383861 – bdoughan Jun 25 '13 at 11:33

1 Answers1

1

Actually my question is bad... i am looking for something like: When is it good to combine StAX and SAX for reading XML files

Whenever possible I would recommend sticking with the StAX APIs. They are faster and IMHO are easier to use than SAX. The exception to this when you are using a ContentHandler to process the XML then SAX is easier. If you hava a StAX XMLStreamReader and need to interact with a ContentHandler then you could use a Transformer for this.

StAXSource source = new StAXSource(xmlStreamReader);
SAXResult result = new SAXResult(conentHandler);
transformer.transform(source, result);
bdoughan
  • 147,609
  • 23
  • 300
  • 400