I'm working with a solution that relies on xpath expressions to gather data. One of those expressions was working just fine until data with special characters showed up.
Example of xml field that contains the data:
<variable id="name" value="STICKS & STONES"/>
This is the xpath expression to fetch data data:
contract/variable[@id \= 'info']/variable[@id \= 'client']/variable[@id \= 'name']/@value
(The backslash preceding the equals sign is required for the application to work).
I tried to replace the entity representation with the & sign :
replace(/contract/variable[@id \= 'info']/variable[@id \= 'client']/variable[@id \= 'name']/@value, '&', '&')
It works, but only fixes this particular case. I want to find a way to deal with all occurrences of entity representations.
Is there a way to "unescape" the content gathered from the xpath expression?
I suppose you can use string()
function to circumvent the semi-colon problem :
string(contract/variable[@id \= 'info']/variable[@id \= 'client']/variable[@id \= 'name']/@value)
should output the desired STICKS & STONES
.