I am trying to extract values from XML data stored as NCLOB column in Oracle db table.
xml structure
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://example.com/FAS/DOC/2011/v3.0b" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record xmlns="http://example.com/FAS/DOC/2011/v3.0b">
<pdate xmlns="http://example.com/FAS/DOC/2011/v3.0b">2014-05-15</pdate>
</record>
</root>
Query
select EXTRACTVALUE(XMLTYPE(nclob_column),'/root/record/pdate','xmlns="http://example.com/FAS/DOC/2011/v3.0b"') pdate1,
EXTRACTVALUE(XMLTYPE(nclob_column),'/root/record/pdate') pdate2
from nclob_table
Problem
The
pdate1does return the value, butpdate2returns null. I cannot use the third parameter of EXTRACTVALUE() to specify the xmlns attribute value as that changes on every row/record. So I get the value for one row but null for all others.
How do I extract the value without specifying the attribute?
Thanks.