I have a problem with counting the number of occurences of a string from an array in a field in an object.
The XML below has 3 'Level3' items with 1 'TextLine' field each.
I need to count how many times each text in the variable 'texts' occurs in the payload.
fun getVasCount(texts) =
sizeOf (Level1.*Level2.*Level3.*TextLine filter (texts contains $))
So instead of getting the count:2 I got the count:3 because 'a text' is a substring of 'This is a text'
var texts = {
"This is a text": "",
"This is another text": ""
}
<?xml version="1.0" encoding="UTF-8"?>
<ns:Level1
xmlns:ns="aaaa:bbbb:cccc:dddd">
<Level2>
<Level3>
<TextLine>This is a text</TextLine>
</Level3>
<Level3>
<TextLine>This is a text</TextLine>
</Level3>
<Level3>
<TextLine>a text</TextLine>
</Level3>
</Level2>
</ns:Level1>
==?