printing [#document: null] means you got a Document object. The getValue() method of a Document object returns null. See the JavaDocs for org.w3c.dom.Node - a vital table for all Java programmers working with DOM which will explain many mysterious results. Bill
And the toString() method of Document, which is what you are implicitly using when you use System.out.println(doc), returns different things in the two Java versions. Note that DOM doesn't specify what toString() should return so it's perfectly acceptable for different implementations of DOM to return different values for toString(). You have just been relying on an undocumented feature.