private static String serializeDocumentInt(Document doc) throws TransformerException, IOException {
  ByteArrayOutputStream s=new ByteArrayOutputStream();
  TransformerFactory factory=TransformerFactory.newInstance();
  Transformer transformer=factory.newTransformer();
  transformer.setOutputProperty(OutputKeys.METHOD,"xml");
  transformer.setOutputProperty(OutputKeys.INDENT,"yes");
  DOMSource source=new DOMSource(doc);
  StreamResult outputTarget=new StreamResult(s);
  transformer.transform(source,outputTarget);
  return s.toString("UTF8");
}

private static String serializeDocumentInt ( Document doc ) throws TransformerException , IOException { ByteArrayOutputStream s = new ByteArrayOutputStream ( ) ; TransformerFactory factory = TransformerFactory . newInstance ( ) ; Transformer transformer = factory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . METHOD , "xml" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; DOMSource source = new DOMSource ( doc ) ; StreamResult outputTarget = new StreamResult ( s ) ; transformer . transform ( source , outputTarget ) ; return s . toString ( "UTF8" ) ; }
serializes a xml document into a string - encoded in utf8 format , with platform line separators .
