As per your suggestion, I tried the following. Unfortunately, this introduces too many "-" in the report file. I will have to do some trial-and-errors.
def getData = { childElement, parentElement = null ->
if (parentElement)
{ xml.'**'.findAll {it.name() == parentElement}."$childElement"*.text() }
else
{ xml.'**'.findAll {it.name() == childElement}*.text()} }
def list = ["\n"+ sdf.format(log_date)+" Seq="+i+","+ data[0],",", msisdn_1,", Status=${getData('errorCode')}", ",", getData('fullName'),",", getData('networkId'),",", getData('code','service'),",", getData('value','avp')]
log.info list.flatten().join('-')
report << list.flatten().join('-')
Report file:
09/13/2021 16:26:12 Seq=20,14313140097-,-14313140097-, Status=[0]-,-PTPT-,-14313140097-,-DATA-ROAMING-VoLTE-SOS-,-Test21-Test22-Test1-Test2-Test3