2016-07-29 87 views
0

我想解析駐留在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 

回答

1

試試這個

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