import com.sap.gateway.ip.core.customdev.util.Message
import groovy.xml.XmlUtil
def Message processData(Message message) {
// Get the header value containing node names to remove
def headerValue = message.getProperty("excludeXMLTags")
if (headerValue) {
// Split the header value by '|' to get a list of node names
def nodeNamesToRemove = headerValue.split("\\|")
// Convert the message body to a string
def payload = message.getBody(String.class)
// Parse the XML
def xml = new XmlSlurper().parseText(payload)
// Remove the specified tags and their content
nodeNamesToRemove.each { tagNameToRemove ->
xml.'**'.findAll { it.name() == tagNameToRemove }.each { it.replaceNode {} }
}
// Convert the modified XML back to a string
def modifiedPayload = XmlUtil.serialize(xml)
// Set the modified payload as the new message body
message.setBody(modifiedPayload)
}
// Return the modified message
return message
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |