XPath Solution :
Using
div[contains(concat(' ', @class, ' '), ' a ') and contains(concat(' ', @class, ' '), ' b ') ]
This selects any child div from the node context whose class attribute contains both the classes "a" and "b" .
If you want the class attribute of any selected div contain exactly (only) these two classes and other classes, use :
div[contains(concat(' ', @class, ' '), ' a ') and contains(concat(' ', @class, ' '), ' b ') and string-length(normalize-space(@class)) = 3 ]
Dimitre novatchev
source share