code: public static String documentToPrettyString(Document document) {
          StringWriter stringWriter = new StringWriter();
          OutputFormat prettyPrintFormat = OutputFormat.createPrettyPrint();
          XMLWriter xmlWriter = new XMLWriter(stringWriter, prettyPrintFormat);
  
          try {
              xmlWriter.write(document);
          } catch (IOException e) {
              // Ignore, shouldn't happen.
          }
  
          return stringWriter.toString();
      }
docs: Returns the given document as a XML string in a "pretty" format.
  
  @param document
  @return the document as an XML string