Groovy script to extract the repeated/particular XML node where the XML has dynamic parent node – SAP CPI
I tried to extract the repeated occurrence of an XML child node from the input, so I blogged and couldn’t found the one which suits my requirement. Hence I am writing this blog to make the use/modify of the script based on the requirement of yours.
Below is the input structure, where I need to extract and concatenate the message node from each dynamic parent node.
Input XML structure
<message>secondary_contact is required</message>
<message>secondary_contact_number is required</message>
<message>workstream_prefix must be a number string</message>
Ouput – secondary_contact is required,secondary_contact_number is required,workstream_prefix must be a number string
Using the above script, I fulfilled my requirements. Hope I will get some suggestions to achieve this in another way.
Appreciating the responses.