Using this code:
xml = new groovy.xml.MarkupBuilder()
xmldata = xml.Plugins(nextid: '10') {
Target(name: 'default.auth') {
Port(protocol: 'https') {
mkp.yield 8080
}
}
}
Generates this output:
<Plugins nextid='10'>
<Target name='default.auth'>
<Port protocol='https'>8083</Port>
</Target>
</Plugins>
But, is there a way to generate the output like this, with double-quotes?
<Plugins nextid="10">
<Target name="default.auth">
<Port protocol="https">8083</Port>
</Target>
</Plugins>
Yes, here’s the documentation.
MarkupBuilder.setDoubleQuotes(true)And in case the link goes bad (copied from the above link, applies to Groovy 2.4.10)
setDoubleQuotes
Sets whether the builder outputs attribute values in double quotes or single quotes.
Parameters:
useDoubleQuotes– If this parameter is true, double quotes are used; otherwise, single quotes are.