Skip to Main Content

DevOps, CI/CD and Automation

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!

searching for nth element via XPATH

41791Jan 29 2002
Hi,
How can I retrieve let say the 4th element label from a well formed and valid XML file? Assumption is the xml file has sequence
of elements with different labels and there are no child in between those elements. I tried for example //ddd[position() mod 4 = 0]and this will get me the 4th ddd from the root, however with this search I have to know ddd is the label. How do I search for the generic nth level element label?

example.xml

<AAA>
<BBB/>
<BVB/>
<ZBB/>
<BBY/>
<RNZ name="x" /> <!-- <- i want to pick this 5th element and its label RNZ -->
<BXS/>
<BBB/>
<ABB/>
<CCC/>
<CCC/>
<CCC/>
</AAA>

Perhaps to put it another way:
How to position one to any arbitrary level node choosen without knowing the label? What if I only know the level as I can visually count it? My understanding is "." is the current
node, but first I need to bring the pointer(?) to this node whatever level or depth it should be.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2002
Added on Jan 29 2002
3 comments
740 views