-1

I have a XML named 'fruits.XML' as follows

<fruits>
    <fruitbasket>
        <id>123 </id>
        <apple>Apple 1 </apple>
        <apple>Apple 2 </apple>
    </fruitbasket>
    <fruitbasket>
        <id> 1 </id>
        <apple>Apple 2 </apple>
        <apple>Apple 3 </apple>
    </fruitbasket>
</fruits>

How to find the baskets with Apple 2 in Xquery? I get a multiple element error when i use the matches in the Query.

tohuwawohu
  • 13,268
  • 4
  • 42
  • 61
Punkster
  • 221
  • 6
  • 17

1 Answers1

1

try this:

 for $element in doc('fruits.xml')//fruitbasket
where $element/apple = 'Apple 2 '
return $element
Kachna
  • 2,921
  • 2
  • 20
  • 34