0
My problem is i want to display the count of all genre that is equals to actions

`

<videos genre="action" count="{
 for $videos in doc("videos.xml")/result/videos/video
 let $count := 0
  
  where $videos/genre ="action" 

 return count($videos/genre)
}"

`

`` but my result is this

the count is=1 1 1 i want the answer is equal to 3



im expecting a result that is 
<videos genre="action" count="3"><video>

1 Answers1

0

You are making it a bit too complicated; try something like:

<videos genre="action" count="{
count(doc("videos.xml")//video[.//genre[.="action"]])
}"/>

or, depending on the struture of you actual videos file, you can use instead

count(//video[.//.="action"])

Those should get you your expected output.

Jack Fleeting
  • 24,385
  • 6
  • 23
  • 45