hi sujith80,
thanks for the feedback, however, how about extracting all the parent node of @id="5" and getting the descendants of @id="3" ?
thanks for your time.
wesley
Main Topics
Browse All Topicshi all,
i've currently using oracle 11g db to store the customer's hierarchical data, i've created an xmltype table referring to a schema that i created myself. my aim is to be able to extract the xml nodes and attributes value.
+be able to extract a list of xmltype node elements along with attributes with xpath axes. "ancestor","descendants",g
would it be possible to just give me a very simple sample code just to do the task mentioned above?
from what i read from oracle, there are few function which i find it very awkard to use. extract(), extractvalue() and existsnode().
perhaps given example,
<country>
<sponsornode id="1" name="johnny">
<sponsornode id="2" name="sam">
<sponsornode id="3" name="mandy">
<sponsornode id="4" name="ken"/>
</sponsornode>
<sponsornode id="5" name="snake"/>
</sponsornode>
</sponsornode>
</country>
the example above is assumed that the sponsornode is nested unlimited.
how do i find all the parent nodes of sponsornode id = "5" in oracle xpath extract statement?
please i need the advise on how to do this, some of the example given from oracle developer doesn't return result. that worries me.
Regards,
Wesley
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
hi there,
i've tried "select column_value from yourtable x, table(xmlsequence(extract(
as to find the child
"select * from yourtable x, table(xmlsequence(extract(
it return all the results as below:
<country>
<sponsornode id="1">
<sponsornode id="2">
<sponsornode id="3">
<sponsornode id="4"/>
</sponsornode>
<sponsornode id="5"/>
</sponsornode>
</sponsornode>
</country>
ids
<sponsornode id="4"/>
based on the structure, it should only return node id 4.
i'm confused.
wesley
//sponsornode[@id="5"]/.. should only return node 2 and from my testing it does.
node 2 contains 3 and 5, and 3 contains 4, so when node 2 is returned you get the whole thing.
It should not return 1 though
If you want just a piece of 2 , which piece do you want?
for //sponsornode[@id="3"]/*
I only get node 4 in my testing...
here are my test cases....
if you get something different then we probably have different setups, please post your test cases
hi sdstuber,
i think i got a misconception here, you are right.
<"so when node 2 is returned you get the whole thing.">
+ my aim is actually to get all the ancestors: given the case previously
to get the ancestor of id="5", what i had in mind was to be able to get the following result
1.<sponsornode id="1" name="johnny"/>
2.<sponsornode id="2" name="sam"/>
for those node even under id=2, i don't need it.
<" If you want just a piece of 2 , which piece do you want?">
can i just get the all the attributes within it?
(eg.)
like ancestor of id=5, i get id=1 and 2, thus be able to have this information.
id=1, name = johnny
id=2, name = sam
(eg.)
for descendant of id=3, information would be.
id=4, name=ken
hope to hear from your advise, thanks
regards,
wesley
Business Accounts
Answer for Membership
by: sujith80Posted on 2008-09-25 at 07:45:15ID: 22569737
This should get you the tag:
select extract(<column name> , '//sponsornode[@id="5"]')
from <your table name>;