获取具有给定值的属性计数 [英] Getting a count of attributes with a given value
问题描述
我正在尝试构建 XQuery
,它将返回找到的值为 x
的数字属性的计数.
I'm trying to construct XQuery
that will return the count of the number attributes found that have a value of x
.
这是 SQL
查询的一部分,这些计数将填充返回的列之一(我可以弄清楚那部分,它是实际的 XQuery
来获取我的计数)还没弄明白.)
This is part of SQL
query and these counts will fill one of the columns returned (that part I can figure out, it's the actual XQuery
to get the count I haven't figured out yet.)
例如,如果我有 <element elementattribute=1>...</element>
,我将如何计算所有等于 1 的 @elementattributes
对于给定的 XML
块?
For example, if I have <element elementattribute=1>...</element>
, how would I count all the @elementattributes
that equal 1 for a given chunk of XML
?
推荐答案
您可以使用星号通配符作为元素名称:
you can use an asterisk wildcard for the element name:
count(///*[@elementattribute='1'])
count(//*[@elementattribute='1'])
希望有帮助...
这篇关于获取具有给定值的属性计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!