Convert a DOM tree into a String.
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
StringWriter sw = new StringWriter();
Result result = new StreamResult(sw);
try {
trans.transform(new DOMSource(domDoc), result);
} catch (TransformerException te) {
System.out.println(te.getMessageAndLocation());
throw te;
}
return sw.toString();