Skip to Main Content

Database Software

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!

XMLTable: position value for a node

gdnoar1Dec 5 2014 — edited Dec 8 2014

I am trying to retreive the XML position value for a node:


create table xmltest

(data XMLTYPE);


insert into xmltest

values ('<fruit><apple/><banana/><orange/></fruit>');

select x.*

from xmltest t,

XMLTable('/fruit'

passing t.data

columns

  orange_index varchar2(10) path 'count(orange/preceding-sibling::*)+1'

) x; 

However this always returns a value of 2 regardless of the node (apple, banna, orange) that is being pointed to by the path expression.  The values I am expectingr are apple=1, banana=2, orange=3.

Does anyone know how to get the position value for a node with XMLTable?

Thanks,

Gary

This post has been answered by odie_63 on Dec 6 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 5 2015
Added on Dec 5 2014
4 comments
2,869 views