0

I am trying to parse the XML below residing in a CLOB column in an Oracle table but it is returning null.

I am trying to retrieve the ElementValue=36 from the below XML.

Please advise.

<?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 used for parsing:

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;

Table definition:

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

1 Answer 1

1

Try this

EXTRACTVALUE(
              xmltype(ATTRIBUTE_CONTENT),
              '/AttributeContent/ContentElements[1]/ElementValue',
               'xmlns="urn:schemas.td.com/ENT/AttributeContent"')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.