For the example HTML below, an XPath query that returns the siblings of the \"a\" elements with class=\'A\' that have class=\'B\' can be written as: //a[@class=\'A\']/foll
//a[@class=\'A\']/foll
You can try this way :
//a[ @class='B' and preceding-sibling::a[@class='A'] and following-sibling::a[@class='A'] ]
Above XPath will select all element(s) between the two elements.