I am having a problem selecting nodes by attribute when the attributes contains more than one word. For example:
<div class="atag btag" />
This is my xpath expression:
//*[@class='atag']
The expression works with
<div class="atag" />
but not for the previous example. How can I select the <div>
?
Best Answer
Here's an example that finds div elements whose className contains
atag
:Here's an example that finds div elements whose className contains
atag
andbtag
:However, it will also find partial matches like
class="catag bobtag"
.If you don't want partial matches, see bobince's answer below.