As one of the approaches you can use XMLSequence() function, which returns a collection of top-level nodes, and then apply extractvalue() to get the actual node value. As another approach, and the preferable one(as of oracle 11gr2 the XMLSequence() has been deprecated), you can use XMLTable() function:
Here is a simple function which returns data of XMLType
data type:
SQL> create or replace function GetXML return xmltype
2 is
3 begin
4 return xmltype('<ROWSET>
5 <ROW>
6 <RCODE>FIRST CHECK DATA</RCODE>
7 </ROW>
8 <ROW>
9 <RCODE>SECOND CHECK DATA</RCODE>
10 </ROW>
11 <ROW>
12 <RCODE>THIRD CHECK DATA</RCODE>
13 </ROW>
14 </ROWSET>');
15 end;
16 /
Function created
Using
XMLSequence()
select extractvalue(column_value, '/RCODE') as rcode from table( xmlsequence( extract(getxml, '/ROWSET/ROW/RCODE') ) )
Result:
RCODE -------------------- FIRST CHECK DATA SECOND CHECK DATA THIRD CHECK DATA
Using
XMLTable()
select Rcode from xmltable('/ROWSET/ROW/RCODE' passing getxml columns Rcode varchar2(21) path '/RCODE')
Result:
RCODE --------------------- FIRST CHECK DATA SECOND CHECK DATA THIRD CHECK DATA