public static String prettyPrint ( String xml ) { LSParser parser = configurer . createLSParser ( ) ; configurer . setParserConfigParameter ( parser , VALIDATE_IF_SCHEMA , false ) ; LSInput input = configurer . createLSInput ( ) ; try { Charset charset = getTargetCharset ( xml ) ; input . setByteStream ( new ByteArrayInputStream ( xml . trim ( ) . getBytes ( charset ) ) ) ; input . setEncoding ( charset . displayName ( ) ) ; } catch ( UnsupportedEncodingException e ) { throw new CitrusRuntimeException ( e ) ; } Document doc ; try { doc = parser . parse ( input ) ; } catch ( Exception e ) { return xml ; } return serialize ( doc ) ; }
Pretty prints a XML string .