on 03-21-2023 2:47 PM
Hi experts,
We have a groovy script for mapping a JSON to XML.
For creating the XML we are using roovy.xml.MarkupBuilder.
// Define XML builder
def writer = new StringWriter()
def builder = new MarkupBuilder(writer)
builder.mkp.xmlDeclaration(version: "1.0", encoding: "utf-8")
What is the way to set up the namespace of the target XML?
Many thanks,
C.
Hi Cristian
Namespace declarations can be added similar to how you add attributes. So something like this:
def sw = new StringWriter()
def builder = new MarkupBuilder(sw)
builder.'n:document'('xmlns:n': 'http://example.org/my/namespace') {
'n:message'('Hello, world!')
}
Regards,
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Many thanks! Issue sorted!
User | Count |
---|---|
81 | |
10 | |
10 | |
8 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.