protected void process(Document document) throws Exception {
// load the transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
// now lets create the TrAX source and result
// objects and do the transformation
Source source = new DocumentSource(document);
StringWriter buffer = new StringWriter();
StreamResult result = new StreamResult(buffer);
transformer.transform(source, result);
String text = buffer.toString();
System.out.println("The document is:- ");
System.out.println(text);
}
Outputs the document using JAXP |