Remember, the resulting datatype of an extract is still XMLTYPE. When you use getStringVal() it will do it's best to give you a meaningful value. If more than one tag is present that matches your extract specification you will get a "multi-rowed" XML document in the resulting XMLTYPE which getStringVal() will display as your results glued together.
You really need to access the data using indexed XPATH like:
SELECT a.col1.extract('/ROWS/MY_TAG[1]/text()')
FROM tab1 a;
Where [1] specifies the first matching tag in the XMLTYPE.
If you want to return a recordset with the elements split up I think your going to have to use a stored procedure to split out the data into a TABLE type then use the TABLE and CAST functions to create a REF CURSOR you can pass out. That may work but I've not tried it. All the individual bits of technology are covered in these articles, but I'm not going to write it for you and I'm not promising it's going to work.
Bookmarks