public static String domToString(Node node) { try { Transformer transformer = TransformerUtils.getXMLIdentityTransformer(); DOMSource source = new DOMSource(node); StringBuilderWriter writer = new StringBuilderWriter(); transformer.transform(source, new StreamResult(writer)); return writer.toString(); } catch (TransformerException e) { throw new OXFException(e); } }
public static String readStreamAsString(Reader reader) throws IOException { final StringBuilderWriter writer = new StringBuilderWriter(); copyStream(reader, writer); return writer.toString(); }