Skip to Content
0
Aug 08, 2023 at 02:11 PM

Change the name of multiple xml nodes in SAP CPI

188 Views Last edit Aug 09, 2023 at 06:11 AM 2 rev

Hi experts

I have a requirement that needs me change the name of multiple nodes of an xml payload.

So, if the Payload looked like this:

<?xml version="1.0"?>

<BrandName>

<L1_Str>

<Channel1>Hotstar</Channel1>

<DATE>2022-05-17</DATE>

<TIME>121859</TIME>

<C_NAME/>

</xml>

I need to change it to:

<?xml version="1.0"?>

<BrandName>

<L1_Str>

<Channel_Name>Hotstar</Channel_Name>

<DATE_R>2022-05-17</DATE_R>

<TIME>121859</TIME>

<C3_NAME/>

</xml>

Could someone please share the groovy script to achieve this? I know there must be a simple way but I am very new to this and am very lost.

Edit:

There is an added requirement now that the nodes need to have spaces between them. The entire data is converted to CSV later. Please let me know how this can be done.

Thank you