Compare element value : Axis « XQuery « XML






Compare element value

File: Data.xml

<prices>
  <priceList>
    <prod>
      <price>29.99</price>
    </prod>
    <prod>
      <price>69.99</price>
    </prod>
  </priceList>
</prices>


File: Query.xquery

if (doc("Data.xml")/prices/priceList/prod[price < 30])
then <bin>{
       doc("Data.xml")/*/priceList/prod[price < 30]
     }</bin>
else ()


Output:

<?xml version="1.0" encoding="UTF-8"?>
<bin>
   <prod>
      <price>29.99</price>
    </prod>
</bin>

 








Related examples in the same category

1.Including elements from the input document
2.Including complex elements from the input document
3.Embedded direct element constructors
4.Enclosed expressions that evaluate to elements
5.Enclosed expressions that evaluate to attributes
6.Enclosed expressions with multiple subexpressions