try
{
// Set up the output transformer
TransformerFactory transfac = TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
// Print the DOM node
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(node);
trans.transform(source, result);
String xmlString = sw.toString();
System.out.println(xmlString);
}
catch (TransformerException e)
{
e.printStackTrace();
}
You need to create an account or log in to post comments to this site.