Would this work? (this is a complete guess) <xsl:value-of select="count(answer/arquements[q1 = 'a1'] AND answer/basicinfo[courseid = 'foodcourse'])"/> If you have the opportunity you might want to re-think how you format your XML data so you can get the answers out that you want. e.g. making courseid an attribute of answer, so that you can filter for this attribute easier. <answer courseid='mathcourse'> <arquements> <q1>a4</q1> <q2>a3</a2> <q3>a1</q3> </arquements> </answer> Or use an XSL transformation to re-jigger the XML into a more qurey friendly format. Then run your query against the newly formatted data.