tags:

views:

54

answers:

1

I'm trying to construct an xquery that will return the count for the number attributes found that have a value of x.

This is part of an 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.)

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?

+1  A: 

Hi, you can use an asterisk wildcard for the element name:

count(//*[@elementattribute='1'])

Hope that helps...

ksclarke
alternatively, you could also do:count(//@elementattribute[.='1'])
ksclarke
Perfect - thanks!