From: "Eric Jain" <[EMAIL PROTECTED]> > > Why don't just use the XMLWriter as it is, there is a write(Element) > method > > in it... > > The issue is that the complete DOM model of the XML file I am writing can't > be loaded into memory at once. Or, put differently, I need to be able to > print as I read.
As Christian just said, you can do exactly this. As you read each Element you can call write(Element) on the XMLWriter. So you don't need the whole document in memory at once. Also notice you can write the open and close of elements. So if you're XML was <rowset> <row>...</row> ... <row>...</row> </rowset> Then you could do... Element rowset = ...; XMLWriter writer = ...; writer.writeOpen(rowset); // foreach row Element row = ...; writer.write( row ); ... writer.writeClose(rowset); That should do the trick. Also note that you can use the above mechanism from inside ElementHandlers, so if you want to perform some filtering/transforming logic in Java then dom4j's ElementHandler and XMLWriter should allow you just to keep as little of the document in RAM as you need, while still using XPath etc. James __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.comm ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user