[英]how to sum all of the count items in xquery
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计数是=1 1 1 我希望答案等于 3
im expecting a result that is
<videos genre="action" count="3"><video>
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.这些应该会让您获得预期的 output。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.