public void write(OutputStream stream) throws Exception {
  String xml;
  xml=toString();
  stream.write(xml.getBytes(),0,xml.length());
  stream.flush();
}

public void write ( OutputStream stream ) throws Exception { String xml ; xml = toString ( ) ; stream . write ( xml . getBytes ( ) , 0 , xml . length ( ) ) ; stream . flush ( ) ; }
writes the current dom document into the given stream .
