通过Oracle中的Extractvalue进行XML解析返回null

问题描述:

我想解析驻留在Oracle表中的CLOB列中的XML,但它返回null。通过Oracle中的Extractvalue进行XML解析返回null

我想从下面的XML检索ElementValue=36

请指教。

<?xml version="1.0" encoding="iso-8859-1"?> 
<AttributeContent xmlns="urn:schemas.td.com/ENT/AttributeContent" xmlns:xsdi="http://www.w3.org/2001/XMLSchema-instance" xsdi:schemaLocation="urn:schemas.td.com/ENT/AttributeContent/AttributeContent.xsd"> 
    <ContentElements> 
    <ElementName>value</ElementName> 
    <ElementValue>36</ElementValue> 
    </ContentElements> 
    <ContentElements> 
    <ElementName>flag</ElementName> 
    <ElementValue>Y</ElementValue> 
    </ContentElements> 
</AttributeContent> 

SQL用于解析:

SELECT EXTRACTVALUE(xmltype(ATTRIBUTE_CONTENT),'/AttributeContent/ContentElements/Elementvalue[1]') 
-- INTO l_batchCycle  
FROM fea_com_ctrl.control_attribute 
WHERE attribute_name = 'BATCH_CYCLE' 
and  end_date is null; 

表定义:

ATTRIBUTE_NAME VARCHAR2(30 BYTE) 
EFFECTIVE_DATE DATE 
END_DATE DATE 
ATTRIBUTE_CONTENT CLOB 

试试这个

EXTRACTVALUE(
       xmltype(ATTRIBUTE_CONTENT), 
       '/AttributeContent/ContentElements[1]/ElementValue', 
       'xmlns="urn:schemas.td.com/ENT/AttributeContent"')