code: public static byte[] serializeDoc(Node n) throws IOException {
          XmlDomWriter xw = new XmlDomWriter();
          ByteArrayOutputStream fout = new ByteArrayOutputStream();
          xw.setOutput(fout, null);
          xw.setCanonical(false);
          xw.write(n);
          fout.close();
          return fout.toByteArray();
      }
docs: Serializes a XML document to a byte array.
  @param n the XML document
  @throws java.io.IOException on error
  @return the serialized XML document