Can XML be generated using Groovy MarkupBuilder with double quotes?

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 output like this with double quotes?

 <Plugins nextid="10"> <Target name="default.auth"> <Port protocol="https">8083</Port> </Target> </Plugins> 
+4
source share
1 answer

Yes, here is the documentation . MarkupBuilder.setDoubleQuotes(true)

And in case the link doesn’t work (copied from the link above, applies to Groovy 2.4.10)


setDoubleQuotes

 public void setDoubleQuotes(boolean useDoubleQuotes) 

Sets whether the linker displays attribute values ​​in double quotation marks or single quotation marks.

Options:

  • useDoubleQuotes - if this parameter is true, double quotes are used; otherwise, single quotes.

+9
source

All Articles