@Override
  public String format(String xml) {
    String formattedString;
    if (xml == null || xml.trim().length() == 0) {
      Platform.get().warn("XML empty.");
      return "";
    }
    try {
      Source xmlInput = new StreamSource(new StringReader(xml));
      StreamResult xmlOutput = new StreamResult(new StringWriter());
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
          String.valueOf(XML_INDENT));
      transformer.transform(xmlInput, xmlOutput);
      formattedString = xmlOutput.getWriter().toString().replaceFirst(">", ">"
          + SystemCompat.lineSeparator);
    } catch (Exception e) {
      Platform.get().warn(e.getMessage());
      return xml;
    }
    return formattedString;
  }
Simply format the XML with a indent of {@value XML_INDENT}.
<br>TODO: Make indent size and enable/disable state configurable.
xlog/src/main/java/com/elvishew/xlog/formatter/message/xml/DefaultXmlFormatter.java