hasOwnProperty is typically not used for xml (for people following the javascript tag, mirth embeds the Mozilla Rhino javascript engine, which uses the deprecated e4x standard for handling xml.) hasOwnProperty does not behave as expected when there are multiple child elements named value
. From the naming convention, I'm assuming it is possible to have multiple values with different codes.
This will create an array for hasCode that holds a boolean for each occurrence of a child element named value.
var hasCode = [];
var hasValue = msg.value.length() > 0;
for each (var value in msg.value) {
// Use this to make sure the attribute named code exists
// hasCode.push(value['@code'].length() > 0);
// Use this to make sure the attribute named code exists and does not contain an empty string
// The toString will return an empty string even if the attribute does not exist
hasCode.push(value['@code'].toString().length > 0);
}
(while length
is a property on strings, it is a method on xml objects, so the parentheses are correct.)
0
Created by agermano on 2020-03-18 19:29:02 +0000 UTC
Share