Ask a Question

Groovy Script: Line Continuation

SOLVED
Mis3
Frequent Contributor

Groovy Script: Line Continuation

Below is a def statement from one of my Groovy Scripts:

 

def MESSAGE4 = holder.getNodeValue("/S:Envelope/S:Body/ns2:getSubscriptionInformationWithInterpretedContentResponse/resultData/interpretedFilesList/interpretedFile/ns2:defaultInterpretedTransparentFileContent/hexaContent")

 

How do I break this line into two to improve readability?

Please help.

Thanks

3 REPLIES 3
nmrao
Community Hero

@Mis3

If 'hexaContent' is unique node in the xml, you can directly use ''//hexaContent" instead of absolute path (which you used)



Regards,
Rao.
Mis3
Frequent Contributor

Yes, it works.   Thanks, .

The new def statement:

def MESSAGE4 = holder.getNodeValue("/S:Envelope/S:Body/ns2:getSubscriptionInformationWithInterpretedContentResponse/resultData//hexaContent")

 

Just for my learning, what if hexaContent is not an unique field under resultData?   Is there a way to split the line into 2 lines?

 

 

nmrao
Community Hero

Have to find a unique way to find xpath to get the get the data.
To get more info on xpath, refer
https://www.tutorialspoint.com/xpath/index.htm

 

What is the issue if it is in a line?

One can use multi-line string in groovy, please see the example.

https://blog.mrhaki.com/2009/11/groovy-goodness-working-with-lines-in.html



Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: