private static byte[] serializeDocument(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();
}

private static byte [ ] serializeDocument ( 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 ( ) ; }
serializes a xml document to a byte array .
