Extracting XML from Oracle XMLType using XPath

May 4, 2016

I wanted to extract some XML from a column in a table. The column was of type XMLType, and the XML that was within it had a Namespace in it.

INSERT INTO drumcoder values ('<fred xmlns="drum"><joe>456</joe></fred>');

The value of the joe tag (456) can be extracted using:

SELECT extractvalue(test, '//joe','xmlns="drum"') from drumcoder;