In postgresql 9.6 the following works:
SELECT xpath(
'text()',
'<hl7_message_host _valuelabel="HL7 host">10.170.117.86</hl7_message_host>');
xpath
-----------------
{10.170.117.86}
(1 row)
But in postgresql 12 it doesn't:
SELECT xpath(
'text()',
'<hl7_message_host _valuelabel="HL7 host">10.170.117.86</hl7_message_host>');
xpath
-------
{}
(1 row)
What am I missing or doing wrong?
The example in this post is much simpler than the real queries in the code: in general the xpath() expression is used to extract/convert (unnest() is often involved) name()+text() or name()+some attributes from the second parameter of xpath, and usually the tagname of the second parameter is not known beforehand, so it can't appear in the first parameter. Also, the second parameter can be many levels nested, but only the 1st one is useful.