Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.INDENT, "yes");
tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
tf.transform(new StreamSource(reader), new StreamResult(writer));
the above code gives me the following result:
<Response>
<Head>ERROR</Head>
<Body>
<ERROR code="1000" reason="ServerSOAPFaultException" description="Fault occurred while processing."/>
</Body>
</Response>
it does not indent xml-attributes, but I need xml-attributes to be indented as well:
<Response>
<Head>ERROR</Head>
<Body>
<ERROR code="1000"
reason="ServerSOAPFaultException"
description="Fault occurred while processing."/>
</Body>
</Response>
How to do it?