I saw the following example on Nabble, where the goal was to return all nodes that contain an attribute with an id of X that contains a value Y:
//find all nodes
def nodeHasValue(node:Node,value:String) = node.attributes.value != null && node.attributes.value.contains(value) (x \\ "_").filter( nodeHasValue(_,"test"))