select current node threw xmlquery [message #460059] |
Wed, 09 June 2010 08:01  |
b_52globemaster
Messages: 51 Registered: July 2005
|
Member |
|
|
hi,
i got a xml data formatted with that form:
<content>
<section>
<section_id>34</section_id>
<section_name>Data</section_name>
<block>
<block_id>34</block_id>
<block_name>RData</block_name>
<block>
<relevantPublications>
<relevantPublicationsTitle>title</relevantPublicationsTitle>
<doc>
<nom>somefile</nom>
<size>156382</size>
<date>2010-05-25 04:46:57</date>
</doc>
</relevantPublications>
</block>
</block>
</section>
</content>
i would to go true the stream and look if there a section_id with the value 34 if it the case it should return the corresponding node /section
any help with that please ?
|
|
|
|
Re: select current node threw xmlquery [message #460092 is a reply to message #460059] |
Wed, 09 June 2010 10:03   |
b_52globemaster
Messages: 51 Registered: July 2005
|
Member |
|
|
Hi Michel,
thanks a lot , one more thing ? how to force o return only the return 34 because not it return all of them.
with
data as (
select xmltype('
<content>
<section>
<section_id>34</section_id>
<section_name>Data</section_name>
<block>
<block_id>34</block_id>
<block_name>RData</block_name>
<block>
<relevantPublications>
<relevantPublicationsTitle>title</relevantPublicationsTitle>
<doc>
<nom>somefile</nom>
<size>156382</size>
<date>2010-05-25 04:46:57</date>
</doc>
</relevantPublications>
</block>
</block>
</section>
<section>
<section_id>389</section_id>
<section_name>Bdat</section_name>
<block>
<block_id>324</block_id>
<block_name>RData</block_name>
<block>
<relevantPublications>
<relevantPublicationsTitle>title</relevantPublicationsTitle>
<doc>
<nom>somefile</nom>
<size>156382</size>
<date>2010-05-25 04:46:57</date>
</doc>
</relevantPublications>
</block>
</block>
</section>
</content>
') xmldata
from dual
)
select extract(xmldata,'//section') v
from data,
TABLE(XMLSequence(extract(xmldata,'//section'))) x
where extractvalue(value(x),'/section/section_id') = 34
it return
Quote:
<section><section_id>34</section_id><section_name>Data</section_name><block><block_id>34</block_id><block_name>RData</block_name ><block><relevantPublications><relevantPublicationsTitle>title</relevantPublicationsTitle><doc><nom>somefile</nom><size>156382 </size><date>2010-05-25 04:46:57</date></doc></relevantPublications></block></block></section><section><section_id>389</section_id><section_name>Bdat </section_name><block><block_id>324</block_id><block_name>RData</block_name><block><relevantPublications><relevantPublicationsTitle >title</relevantPublicationsTitle><doc><nom>somefile</nom><size>156382</size><date>2010-05-25 04:46:57</date></doc></relevantPublications></block></block></section>
and thanks
|
|
|
Re: select current node threw xmlquery [message #460094 is a reply to message #460092] |
Wed, 09 June 2010 10:19  |
 |
Michel Cadot
Messages: 68418 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
With all the examples I gave you maybe you should try to find by yourself and come back with your tries or solution before I still spent hours to find answers for you.
It would be nice if I can see that my time was spent learning you something and not just doing your work.
Regards
Michel
|
|
|