I am currently working on a code that aims to retrieve a path value from an XML file. If the path is not found, I want to set it to blank.
Interestingly, I encounter errors when I use try/catch blocks, stating that the "path" cannot be found. However, when I remove the try/catch, the path is found without any issues. Is there something specific about try/catch that I might be overlooking?
Another point to mention is that I am using try/catch because when I attempt to set my code variable, an error occurs if the path is not found. I am looking for a solution where if the path is not found, it will simply be blank and the program will continue running.
Thank you for any insights!
for (i = 0; i<listLength; i++){
var path = msg['section']['organizer']['site'][i]['section']['code']['@code'].toString()
if (path == "1234-5"){
for (x = 0; x<count; x++){
try{
var code = msg['component']['structuredBody']['component']['section']['entry'][x]['act']['entryRelationship'][0]['observation']['participant']['participantRole']['playingEntity']['code']['@code'].toString()
}
catch(err){
code = ""
}