code: public static String xmlToString(Document document) throws Exception {
          if (transformer == null) {
              throw new Exception("Transformer is null");
          }
          Source xmlSource = new DOMSource(document);
          StringWriter stringWriter = new StringWriter();
          Result result = new StreamResult(stringWriter);
          transformer.transform(xmlSource, result);
          return stringWriter.toString();
      }
docs: Convert XML {@link Document} to its string representation.
  
  @param document for conversion
  @return - string representation of XML {@link Document}
  @throws Exception - if {@link DocumentBuilder} is not initialized