code:     public static void writeXml(Node n, OutputStream os) throws TransformerException {
          TransformerFactory tf = TransformerFactory.newInstance();
          // identity
          Transformer t = tf.newTransformer();
          t.setOutputProperty(OutputKeys.INDENT, "yes");
          t.transform(new DOMSource(n), new StreamResult(os));
      }
  
  