Groovy Script: Line Continuation
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If 'hexaContent' is unique node in the xml, you can directly use ''//hexaContent" instead of absolute path (which you used)
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it works. Thanks, nmrao.
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
