How is it possible to select an html element that have two classes?

For example, how to select the element <p> bellow in an HTML document (given that it has two css classes) class='class1 class2'.

I tried to use the following:

  • doc.xpath("//p[@class~='class1 class2']")
  • doc.xpath("//p[@class~='class1']|[@class~='class2']")
  • doc.xpath("//p[@class~='class1',@class~='class2']")
  • doc.xpath("//p[contains(concat(' ', @class, ' '), ' class1 ') && contains(concat(' ',@class, ' '), ' class2 ')]")

but without success.

Thanks in advance

Edit
Report