I am having a problem selecting nodes by attribute when the attributes contains more than one word. For example:
>
mjv's answer is a good start but will fail if atag is not the first classname listed.
The usual approach is the rather unwieldy:
//*[contains(concat(' ', @class, ' '), ' atag ')]
this works as long as classes are separated by spaces only, and not other forms of whitespace. This is almost always the case. If it might not be, you have to make it more unwieldy still:
//*[contains(concat(' ', normalize-space(@class), ' '), ' atag ')]
(Selecting by classname-like space-separated strings is such a common case it's surprising there isn't a specific XPath function for it, like CSS3's '[class~="atag"]'.)