code: public static String printNode(Node node, boolean prettyprint)
     {
        StringWriter strw = new StringWriter();
        new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
        return strw.toString();
     }
docs: Print a node with explicit prettyprinting.
  The defaults for all other DOMWriter properties apply.