Companion is a docker image you can install to your Windows/Mac/Linux that will give you tools like "Flow Diff", "Credentials Where-used", "Flow Image".
CSV to XML Example (Manual)
This script example is contributed by Suraj Shelke.
It illustrates how you can work with splitting, arrays, and loops in Groovy.
Since there might be many edge cases with CSV, you should also consider using a library like Apache Commons CSV.
Script
Try it on
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.xml.XmlUtil
def Message processData(Message message) {
//Body
def body = message.getBody(String);
def lines = body.trim().split('\n')
def headers = lines[0].split(',')
def data = lines[1..-1].collect { it.split(',') }
def xml = new StringBuilder()
xml.append('<root>')
data.each {
row ->
xml.append('<record>')
headers.eachWithIndex {
header,
index ->
xml.append("<${header}>${row[index]}</${header}>")
}
xml.append('</record>')
}
xml.append('</root>')
def formattedXml = XmlUtil.serialize(xml.toString())
message.setBody(formattedXml)
return message;
}