But that's not correct, toString() method prints text representation of document.
Look at the JavaDocs for org.w3c.Node - specifically the table showing what the nodeName and nodeValue values are - note that a Document Node returns null for nodeValue.
Now, is some implementations of the DOM, Document.toString returns a full text
string BUT in the
Java 1.5 implementation, toString returns the result of a call to nodeValue() which is - as seen above - null.
Document is an interface so it does NOT dictate what toString() should return. This has caused a lot of confusion and hunting for bugs that do not exist.
Bill