The issue as I understand it is ... Instead of building the model totally in memory and writing it, which could potentially be expensive, the XMLWriter also supports writing the information bit by bit with the bonus that the output can formatted and that characters are substituted.
You could according to the API use the openElement and closeElement methods to stream the element tags. The following code for instance should be a lot less memory expensive: <code> XMLWriter xmlWriter = new XMLWriter( writer, OutputFormat.createPrettyPrint()); Namespace ns = DocumentHelper.createNamespace( "tst", "http://www.tst.com/"); QName rname = DocumentHelper.createQName( "root", ns); Element root = DocumentHelper.createElement( rname); xmlWriter.writeOpen( root); QName ename = DocumentHelper.createQName( "element", ns); for ( int i = 0; i < 1000; i++) { Element element = DocumentHelper.createElement( ename); element.addAttribute( "id", ""+i); xmlWriter.writeOpen( element); xmlWriter.writeClose( element); } xmlWriter.writeClose( root); xmlWriter.flush(); xmlWriter.close(); </code> However this does not at the moment handle namespaces correctly. Regards, Edwin -- http://www.edankert.com/ ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user