/** * Returns the generated XML as string, using UTF-8 as encoding. * * @return a string representation of the generated XML. */ public String generate() { return generate(Charsets.UTF_8.name()); }
/** * Writes the given XML document to the given writer. * * @param doc the XML document to write * @param writer the target to write the XML to * @param encoding the encoding used to write the XML * @throws javax.xml.transform.TransformerException if an exception during serialization occurs. */ public static void writeXML(Node doc, Writer writer, String encoding) throws TransformerException { writeXML(doc, writer, encoding, false); }
@Override public String toString() { try { StringWriter writer = new StringWriter(); XMLGenerator.writeXML(node, writer, Charsets.UTF_8.name(), true); return writer.toString(); } catch (Exception e) { Exceptions.handle(e); return node.toString(); } } }
private String serializeNodeAsXML(Node result) { try { StringWriter writer = new StringWriter(); XMLGenerator.writeXML(result, writer, Charsets.UTF_8.name(), true); return writer.toString(); } catch (Exception e) { Exceptions.handle(e); return null; } }