src/main/java/com/rockagen/commons/util/XmlUtil.java
public static String formatCompact(String xmlStr, String enc,
                                       boolean isSuppressDeclaration) {

        if (CommUtil.isBlank(xmlStr))
            return xmlStr;

        if (enc == null)
            enc = ENCODING;

        OutputFormat formater = OutputFormat.createCompactFormat();
        formater.setEncoding(enc);
        formater.setSuppressDeclaration(isSuppressDeclaration);
        return format(xmlStr, formater);
    }
public static String formatCompact(String xmlStr, String enc,
                                       boolean isSuppressDeclaration) {

        if (CommUtil.isBlank(xmlStr))
            return xmlStr;

        if (enc == null)
            enc = ENCODING;

        OutputFormat formater = OutputFormat.createCompactFormat();
        formater.setEncoding(enc);
        formater.setSuppressDeclaration(isSuppressDeclaration);
        return format(xmlStr, formater);
    }
Format xml {@link OutputFormat#createCompactFormat()}

@param xmlStr                xml String
@param enc                   encoding
@param isSuppressDeclaration set supperss declaration
@return Compact xml String