XPath: How to check if an attribute exists?
Short and sweet:
//*[@foo]
Of course you should use a more specific expression. But with [@attributeName]
you get all nodes which have that attribute.
Use the following XPath expression
//*[boolean(@foo)]
If you use and xpath, this maybe can help you:
count(//*[@foo])
it will return count of node/child that have attribute foo