public static String toString(Node node) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Transformer transformer = createTransformerFactory().newTransformer();
            transformer.setOutputProperty(OutputKeys.ENCODING, UTF_8.name());
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            transformer.transform(new DOMSource(node), new StreamResult(out));
        }
        catch (TransformerException e) {
            throw new IllegalArgumentException("invalid XML element", e);
        }
        return out.toString(UTF_8);
    }
Returns the UTF-8 string representation of an XML root, tag or text node.
vespajlib/src/main/java/com/yahoo/text/XML.java