XML XML Prefix

I have a simple question about the Java XML API, and I hope that there will be a simple answer:

Suppose that after processing I have the following XML output:

<a>
    <b><c>
    <d> <e> some content
        </e>    </d>
    </c>    </b>
</a>

The structure is correct, but spaces are everywhere. The question is, how can I prefix the output so that it looks something like this:

<a>
    <b>
        <c> 
            <d>
                <e>some content</e>
            </d>
        </c>
    </b>
</a>

Only to catch that I cannot use anything but the Java 5 native XML API.

+5
source share
2 answers
+4
source

Try it.

transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2")

This does not work for me either. WTF? java version "1.6.0_29"

Transformer.setOutputProperty(OutputKeys.INDENT, "yes")
0

All Articles