I have a very large xml file which I have stored in a longtext field called xml, in a table called imports.
Then I store todays xml string in a user variable called @xml like this.
SELECT xml FROM imports WHERE DATE(updated_at) = DATE(NOW()) INTO @xml;
I can test the user variable and the length of the data is there as expected.
SELECT LENGTH(@xml);
Testing the position of my target xml tag also works as expected.
SELECT LOCATE('sm:ProductCode>', @xml);
However when I try to use the ExtractValue with an XPath query that contains the namespace, I get null. This XPath query is tested and working fine in my XPath exploring software.
SELECT ExtractValue(@xml, '//sm:ProductCode');
It is supported as of 5.1.10:
If your version is older, then there’s nothing you can do, the XPath
namespace-uri()function, that you could have used as a workaround, is not supported.