public static String serialize ( Document doc ) { LSSerializer serializer = configurer . createLSSerializer ( ) ; LSOutput output = configurer . createLSOutput ( ) ; String charset = getTargetCharset ( doc ) . displayName ( ) ; output . setEncoding ( charset ) ; StringWriter writer = new StringWriter ( ) ; output . setCharacterStream ( writer ) ; serializer . write ( doc , output ) ; return writer . toString ( ) ; }
Serializes a DOM document