开发者

Creating XML file with identation

开发者 https://www.devze.com 2023-01-26 15:53 出处:网络
How can I create开发者_JAVA技巧 a XML file that has identation or, at least, line breaks between each tag?

How can I create开发者_JAVA技巧 a XML file that has identation or, at least, line breaks between each tag?

I'm using class XMLSerializer (available in Android) to handle the XML creation.

XMLSerializer serializer = new XMLSerializer();
StringWriter writer = new StringWriter();

serializer.setOutput(writer);
String xmlFileContents = writer.toString();

Then I use the contents of xmlFileContents to create a file, using a BufferedWriter. The file is written, but the XML is not idented, and would like it to be.

Thanks.


already solved: How to indent XML properly using XMLSerializer?

0

精彩评论

暂无评论...
验证码 换一张
取 消