JSON Databank Xpath

I am trying to get a value from xpath and when I "Evaluate XPath" I get the correct value. When I execute at runtime the value = null on the console. If I hard code the value(position) it writes to console.
Here is my xpath: /root/addressRelations/item[id/addressTypeId/text()='PR']/address[1]/city/text()
I am using 2024.1 and 2024.2. I have done many xpaths like this with conditions on a repeating segment with no issues before. Is there a setting somewhere? Thoughts?
Best Answer
-
item[id/addressTypeId/text()='PR']
The value in your JSON is "PR " (two spaces) and not "PR". You could do one of the following instead:
item[id/addressTypeId/text()='PR ']
or
item[normalize-space(id/addressTypeId/text())='PR']
when I "Evaluate XPath" I get the correct value
The button operates on a pretty-printed version of the XML representation where whitespace is normalized. At runtime, the XPath operates on the original message.
0
Answers
-
Can you provide a sample JSON document? What the XPath will or will not match really depends on what it is being evaluated against.
0 -
-
that worked. The learning gained here is to always use "normalize-space". thx
0