cancel
Showing results for 
Search instead for 
Did you mean: 

Remove xml nodes with child nodes on CPI.

0 Kudos
1,302

Hello,

how to Remove xml nodes with child nodes on CPI.

input

<Lead ActionCode="01"> <Account> <Name1>Yasser Taysser</Name1> <CountryCode>GR</CountryCode> <MobileFormattedNumberDescription>+201116116210</MobileFormattedNumberDescription> </Account> <Campaign> <ID>0000000849</ID> <Version>1</Version> <Name>New Lead Transfer 18.09.2022 - co - copy</Name> </Campaign>

<Contact> <Name1>Name</Name1> <PersonFirstName>First name</PersonFirstName>

</Contact>

</lead>

Expected output (Remove Account section)

<Lead ActionCode="01"> <Campaign> <ID>0000000849</ID> <Version>1</Version> <Name>New Lead Transfer 18.09.2022 - co - copy</Name> </Campaign>

<Contact> <Name1>Name</Name1> <PersonFirstName>First name</PersonFirstName>

</Contact>

</lead>

Accepted Solutions (0)

Answers (1)

Answers (1)

MortenWittrock
SAP Mentor
SAP Mentor

Hi

You can solve this using XSLT and the method I described in this blog post: Thinking in XSLT: Filtering XML elements.

In your case, the solution looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:mode on-no-match="shallow-copy" />
<xsl:output method="xml" indent="yes" />
<xsl:template match="/Lead/Account" />
</xsl:stylesheet>

Add this stylesheet in an XSLT mapping step to your iflow, and it will remove the Account element from the payload.

Regards,

Morten

0 Kudos

Thanks Morten,

can be handled using groovy script ?

Regards.

MortenWittrock
SAP Mentor
SAP Mentor
0 Kudos

Hi hananghannam

Sure, it can be done in Groovy as well. But please post a separate question.

Regards,

Morten