XML整形

メモ。

// エンコーディング指定
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
// XMLを整形する方法
transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
transformer.setOutputProperty(javax.xml.transform.OutputKeys.METHOD, "xml");
transformer.setOutputProperty(org.apache.xml.serializer.OutputPropertiesFactory.S_KEY_INDENT_AMOUNT, "2");