title: create json from dom document
body: <p>I have a org.w3c.dom.Document.
  To generate the xml is no problem.
  But how can I generate json out of the document ?</p>
  
  <p>this is the code to get the xml string</p>
  
  <pre><code>        TransformerFactory transfac = TransformerFactory.newInstance();
          Transformer trans = transfac.newTransformer();
          trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
          trans.setOutputProperty(OutputKeys.INDENT, "yes");
  
          // create string from xml tree
          StringWriter sw = new StringWriter();
          StreamResult result = new StreamResult(sw);
          DOMSource source = new DOMSource(document);
          trans.transform(source, result);
          String xmlString = sw.toString();
  </code></pre>