Code example for Transformer

Methods: setOutputProperty, transform

0
    @Override 
    protected String writeAsString(Element element) throws Exception { 
        TransformerFactory transFactory = TransformerFactory.newInstance(); 
        Transformer transformer = transFactory.newTransformer(); 
        StringWriter buffer = new StringWriter(); 
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); 
        transformer.transform(new DOMSource(element), 
                new StreamResult(buffer)); 
        return buffer.toString(); 
    } 
 
    @Override 
    protected TestSolnaHandler<Element> createHandler() { 
        return new TestSolnaHandler<Element>(){}; 
    } 
}