code: public static String nodeToString(final Node node) {
          try {
              final Transformer t = TransformerFactory.newInstance().newTransformer();
              t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
              final StringWriter sw = new StringWriter();
              t.transform(new DOMSource(node), new StreamResult(sw));
              return sw.toString();
          } catch (final TransformerException ex) {
              throw new RuntimeException("Failed to render node", ex);
          }
      }
docs: Render a node as string.
  
  @param node
  Node to render.
  
  @return XML.