繁体   English   中英

如何对xquery中的所有计数项求和

[英]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)
}"

`

`` 但我的结果是这样的

计数是=1 1 1 我希望答案等于 3



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

你让它有点太复杂了; 尝试类似的东西:

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

或者,根据您实际视频文件的结构,您可以改用

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

这些应该会让您获得预期的 output。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM