void buildNodes(node, builder) {
node.children().each { child ->
if (child.children().size() > 0) {
builder."${child.name()}"(child.attributes()) {
buildNodes(child, builder)
}
} else {
builder."${child.name()}"(child.attributes(), "${child.text()}")
}
}
}
import groovy.xml.MarkupBuilder
import groovy.util.XmlSlurper
import com.sap.gateway.ip.core.customdev.util.Message
import groovy.xml.XmlUtil
def Message processData(Message message) {
def body = message.getBody(Reader)
def parsedXml = new XmlSlurper().parse(body)
// Some weird coding hacking the world or just an invoice
// Create sorted InvoiceRequest
def writer = new StringWriter()
def xmlOutput = new MarkupBuilder(writer)
xmlOutput.InvoiceRequest {
Invoice {
SupplierInvoiceID(parsedXml.Invoice.SupplierInvoiceID)
SupplierInvoiceTypeCode(parsedXml.Invoice.SupplierInvoiceTypeCode)
DocumentDate(parsedXml.Invoice.DocumentDate)
items.each { item ->
Item {
buildNodes(item, xmlOutput)
}
}
}
}
message.setBody(writer.toString())
return message
}
void buildNodes(node, builder) {
node.children().each { child ->
if (child.children().size() > 0) {
builder."${child.name()}"(child.attributes()) {
buildNodes(child, builder)
}
} else {
builder."${child.name()}"(child.attributes(), "${child.text()}")
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
9 | |
9 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 |