Search code examples
phpdomdocumentdomxpath

DOMXpath get from different classes


i have something like this:

<div class='rand'>
    some text...
</div>
<div class='rand1'>
    some text..
</div>
<div class='rand2'>
    some text..
</div>
.
.
.

I want to take from all the different divs only those whose class='rand' or class='rand2' all in one DOMXpath query..
Any ideas?


Solution

  • Xpath:

    //div[@class='rand' or @class='rand2']
    

    Here are examples on how to run the xpath query: Parse HTML with PHP's HTML DOMDocument