Q: xpath - how to union queries with priority of query I want to combine 3 queries with union operator "|" which is working fine, 
but I want to set priority per every query, so for example if first query will bring result then it needs to be node[0]
example : //div[@class='class1'] | //div[@class='class2'] | //div[@class='class3']
so if string have more than 1 query matches that it needs to follow some priority or even better do not bring any results on other queries if one before have some matches
Please help
Thank You

A: If you only want one node in the result, then the usual approach (assuming XPath 2.0 or higher) is:
(//div[@class='class1'], //div[@class='class2'], //div[@class='class3'])[1]

If there might be several nodes with @class='class1', and you want all of them, and you only want nodes with @class='class2' if there are none with @class='class1', then it's a bit more difficult. But before we go any further, you need to tell us which version of XPath you are using.

A: //div[@class='class1'] | //body[not(div[@class='class1'])]/div[@class='class2'] | //body[not(div[@class='class1'] and not(div[@class='class2']))]/div[@class='class3'] 
if class1 exists, then 2nd and 3rd xpath will result to nothing, if class 2 exists then 3rd xpath will result to nothing..
that's the idea, but you have to work on it further...be creative my man.
