indent XML text with Transformer

后端 未结 1 1010
南旧
南旧 2021-01-25 18:40

I\'m writing an XML file with the following code:

Source source = new DOMSource(rootElement);
Result result = new StreamResult(xmlFile);
Transformer transformer          


        
1条回答
  •  无人及你
    2021-01-25 19:00

    You may have to specify the amount of spaces to indent as well:

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

    0 讨论(0)
提交回复
热议问题