code: public static String convertXmlDocumentToString(DomDocument document) {
      StringWriter stringWriter = new StringWriter();
      StreamResult result = new StreamResult(stringWriter);
      transformDocumentToXml(document, result);
      return stringWriter.toString();
    }
docs: Converts a {@link DomDocument} to its String representation
  
  @param document  the XML document to convert