Hello Per, I don't know of anything existing that does what you want. But, in Groovy you can easily define structures like JSON or XML (which both give you a structure but does so using different formats.
Example: Map<String, Object> root = [ "id": "QAZ", "name" : "Nisse", ... ] This is a java.util.Map structure. Your code can then take this Map<String, Object> and convert to JSON or XML. But I don't know of anything existing that takes such a Map structure to XML. I would not be entirely surprised if such exists. In my current project I'm using the Groovy Map shortcut [ : ] to build structured information. In my case it will be converted to JSON and potentially other structured formats later. But as long as you have the information stored in some structured way it should be relatively easy to convert to XML. Reading both JSON and XML is by far more difficult than producing them. Best Regards, Tommy Svensson On 18 May 2025 at 20:38 +0200, Per Nyfelt <p...@alipsa.se>, wrote: > Hi, > > I would like to have a user api that can handle the following: > > createXml(target: xmlFile, name: 'a test') { > > description('test xml') > > licenses { > license('Apache License, Version 2.0', > 'http://www.apache.org/licenses/LICENSE-2.0') > } > > } > > // description and licenses are arbitrary, it can be any structure that > can be converted to XML > > I want the closure to behave as if it would be statements to a > MarkupBuilder but I am unable to figure out how to do it. Can i convert > the closure to a MarkupBuilder or process it with a MarkupBuilder > somehow? Any ideas? > > Best regards > > Per >