有没有办法控制 groovy 的 MarkupBuilder 的输出并过滤掉换行符?我有如下代码:
import groovy.xml.MarkupBuilder
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.basket(){
fruit (type:"apple", 1)
fruit (type:"orange", 2)
}
它总是输出:
<basket>
<fruit type='apple'>1</fruit>
<fruit type='orange'>2</fruit>
</basket>
我真的很喜欢单行:
<basket><fruit type='apple'>1</fruit><fruit type='orange'>2</fruit></basket>