0
<div id="test">
<span>Don't select me</span>
<span>Select me</span>
</div>

I want to select second span in div#test.
Exist eq() selector (like jQuery) or something like that?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Andrey Vorobyev
  • 896
  • 1
  • 10
  • 37

1 Answers1

1

Unfortunately Zend_Dom_Query doesn't support the :nth-child(n) selector from css, but reverting back to xpath to query you could write:

 $result = $dom->queryXpath('//div[@id="test"]/span[2]');

The Zend_Dom_Query library uses xpath behind a scenes to execute CSS style queries so, if you got struck with xpath syntax, you can take a sneak peek into what's it generated with the getXpathQuery method on the result objects.

complex857
  • 20,425
  • 6
  • 51
  • 54