0

I have an issue where I have a div that doesnt have a class or id. Is it possible to select an div element when I know its innerText ie

<div class="thishere"></div>
<div>Search on a this text</div>

If not, the div before it has a class, how do i find its next sibling?

$selector = new Zend_Dom_Query($response->getBody());
$nodes = $selector->query('????');
madphp
  • 1,716
  • 5
  • 31
  • 72

2 Answers2

0

Using JavaScript you can loop through every element on the page like this says and find that div with the special class. Then, you'll know that the next element in the loop will be that second div and you can get its contents using element.innerHTML.

Community
  • 1
  • 1
CFL_Jeff
  • 2,589
  • 3
  • 31
  • 49
0
        $text = <<<text
<div class="thishere"></div>
<div>Search on a this text</div>

text;

        $selector = new Zend_Dom_Query ($text);

        $nodes = $selector->queryXpath('//div[contains(text(),"Search on a this text")]');
        foreach ($nodes as $node)
        {
            ...
        }
akond
  • 15,865
  • 4
  • 35
  • 55