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!

Get parent node id, XPATH and DEPTH from an XML using SQL PL/SQL

ShrikantBMay 27 2014 — edited Jul 15 2014

Hi I am using Oracle 11g R2

I have following XML

<ROOT>

  <first_Child>

  <l1>527029</l1>

  <l2>16257659-1</l2>

  <l3>false</l3>

  </first_Child>

  <second_child>

  <l4>2014-01-03</l4>

  <l5>Y</l5>

  </second_child>

</ROOT>

I want the Parent  node id, XPATH and depth of each node

Required output

node_name     parent_id     XPATH                        DEPTH         

ROOT                              /ROOT                              0              

first_child         0               /ROOT/FIRST_CHILD        1

l1                    1               /ROOT/FIRST_CHILD/L1    2

.....

.....

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 12 2014
Added on May 27 2014
27 comments
12,166 views