Question : Parsing XML in Oracle

I have a XML document that looks like this:

  111
  222
  333


let say i store it in a table XMLTAB inside the column XMLTXT which is in CLOB datatype. Now I want to parse it using this SELECT:

SELECT EXTRACT(XMLTYPE(xmltxt), '//CHILD/text()','xmlns="http://testxml"').getStringVal() AS VALUE
FROM xmltab;

Now it returns the value of the child but it looks like this:

111222333

Is there a way where I can display them as rows? Like this:

111
222
333

Answer : Parsing XML in Oracle

do you have a namespace on your xml?

if not, don't specify one

from original example

SELECT EXTRACTVALUE(VALUE(x), '/CHILD') AS VALUE
FROM   xmltab, table(XMLSEQUENCE(EXTRACT(xmltype(xmltxt), '//CHILD'))) x


with your second example


SELECT EXTRACTVALUE(VALUE(x), '/item') AS VALUE
FROM   clobxml, table(XMLSEQUENCE(EXTRACT(xmltype(xmltxt), '//animals/item'))) x
Random Solutions  
 
programming4us programming4us