我正在使用XML MarkupBuilder来生成XML文件
import groovy.xml.StreamingMarkupBuilder
import groovy.xml.MarkupBuilder
import org.custommonkey.xmlunit.*
....
def xmlObj = new StringWriter()
def xml = new MarkupBuilder(xmlObj)
xml.book("id":21){
name('bookname')
}
我得到输出:
<book id='21'>
<name>bookname</name>
</book>
如何使其生成根XML标签?
<?xml version="1.0" encoding="utf-8"?>