Reputation: 3496
I'm trying to determine whether an xml tag has two specific child tags.
The XML Clob has a format like this:
<ProductS>
<id>1</id>
<Discount></Discount>
<Promotion></Promotion>
</ProductS>
<ProductS>
<id>2</id>
<Discount></Discount>
</ProductS>
I want my xmlquery to go through this XML clob and identify if there is an xml tag that contains these two discount and promotion types under ProductS.
My code currently looks like this:
select existsNode(xmltype(rec1.xml), '/ProductS/Discount') into v_node_exists_discount from dual;
select existsNode(xmltype(rec1.xml), '/ProductS/Promotion') into v_node_exists_promotion from dual;
Will ANDing these two statements above work in this type of scenario or do I need to do something else.
Thanks.
Upvotes: 0
Views: 311
Reputation: 89325
I'm not familiar with oracle but you can easily query <ProductS>
having both <Discount>
and <Promotion>
using single xpath like so :
/ProductS[Discount and Promotion]
The oracle query might look about like this :
select existsNode(xmltype(rec1.xml), '/ProductS[Discount and Promotion]')
into v_node_exists_discount_and_promotion
from dual;
Upvotes: 3