Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
4 years ago

How to assign attributes of a node to variables to output to a log file?

Not sure how to assign the attributes of a node to variables so I can output to a log file.  Please help. The request contains 8 API and the result contains 9 responses (1 for the whole request and ...
  • nmrao's avatar
    nmrao
    4 years ago

    Mis3 

    Here you go:

     

     

    If that is output you need? Then please use

     

     

    //Assuming you have data array, variable i, and xmlString
    //Apart from that you can remove everything from the script
    def line = ["Seq=${i}", data[0], data[1] ]
    line << new XmlSlurper().parseText(xmlString).'**'.findAll {it.name() == 'sdmDataResponse' }.collectMany{ ["FlowId=${it.@flowId}", "Status=${it.children()[0].@resultCode}" ]}
    log.info line.flatten() 

     

  • nmrao's avatar
    nmrao
    4 years ago
    I thought I saw those brackets from your response.

    Just change
    line.flatten()
    To
    line.flatten().join(',')