Java中的StAX XML格式 [英] StAX XML formatting in Java
本文介绍了Java中的StAX XML格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能使用StAX(特别是woodstox)来格式化输出xml的换行符和制表符,例如:
< ; element1>
someData
而不是:
< element1>< element2> someData< / element2>< / element1>< / pre>
如果这在woodstox中是不可能的,是否还有其他的轻量级库可以做到这一点?
解决方案通过JDK:transformer.setOutputProperty(OutputKeys.INDENT,yes);
。Is it possible using StAX (specifically woodstox) to format the output xml with newlines and tabs, i.e. in the form:
<element1> <element2> someData </element2> </element1>instead of:
<element1><element2>someData</element2></element1>If this is not possible in woodstox, is there any other lightweight libs that can do this?
解决方案Via the JDK:
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
.这篇关于Java中的StAX XML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文