XML : Stream XML node by node

I have found examples how to stream whole documents but is there a way to stream node by node so I don't get a memory problem if the file is too big?

  private Document document;   private void stream(OutputStream out) {      // write the doc into stream      TransformerFactory transformerFactory = TransformerFactory.newInstance();      Transformer transformer;      DOMSource source = new DOMSource(document);      StreamResult result = new StreamResult(out);        try {          transformer = transformerFactory.newTransformer();          transformer.transform(source, result);      } catch (TransformerException e) {          throw new RuntimeException("couldn't stream result to output");      }  }    

No comments:

Post a Comment