XPath can find only childs ev('.//div[@class="parent"]/div[@class="children"]');
, but not siblings sadly and I need to find all occurrences of sequence:
<div class="1"></div><div class="2"></div><div class="3">
not when only one of those is present or they are present in the wrong order, what can you suggest to achieve this result?
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'])]