Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Extract XML attributes into table rows

MirithuMay 31 2020 — edited May 31 2020

Hello,

I am using SQL Developer on Oracle Database 12c Enterprise Edition Release 12.1.0.2.0.

I have a table with an xmltype column whose data appears as follows:

  

RECIDXMLRECORD
1-1.1<row id='1-1.1' xml:space='preserve'><c1>Value1</c1><c1 m='2'>Value2</c1><c1 m='3'>Value3</c1><c2>ValueA</c2><c2 m='2'>ValueB</c2><c2 m='3'>ValueC</c2></row>

I would like to extract the elements and attributes into a table as below:

   

RECIDValueNumberValueText
1-1.1Value1ValueA
1-1.1Value2ValueB
1-1.1Value3ValueC

Kindly advice how I can achieve this. I have tried using extract() together with regexp_substr to no avail.

Thank you.

This post has been answered by cormaco on May 31 2020
Jump to Answer
Comments
Post Details
Added on May 31 2020
5 comments
1,408 views