Friday, 5 April 2019

XML tag/XML Node removal from XML data


When required to remove the xml tag from the xml data for the futher transformation steps, then below grovvy script will be used to achieve this functionality.

Groovy Script:


import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.io.*;


def Message processData(Message message) {

//Body

def body = message.getBody(java.lang.String) as String;

body = body.replaceAll("\\<\\?xml(.+?)\\?\\>", "").trim();

message.setBody(body);

return message;

}



No comments:

Post a Comment