I'm not 100% sure whether I interpret your boundary conditions correctly but in case you want to detect exactly the sequence with respect to <div>
with potentially other tags in between you can use this expression:
.//div[@class='1' and (following-sibling::div)[1][@class = '2'] and ((following-sibling::div)[2][@class = '3'])]
This would return the occurences of <div class='1'>
. Of course, you can easily change this to return the other occurences with class='2'
or class='3'
.
If you want to exclude the potential occurence of other tags in between you can use:
.//div[@class='1' and (following-sibling::*)[1][local-name()='div' and @class = '2'] and ((following-sibling::*)[2][local-name()='div' and @class = '3'])]