duzun / hQuery.php

An extremely fast web scraper that parses megabytes of invalid HTML in a blink of an eye. PHP5.3+, no dependencies.
https://duzun.me/playground/hquery
MIT License
361 stars 74 forks source link

How to retrieve next element? #8

Closed chimmel closed 8 years ago

chimmel commented 8 years ago

foreach($prod->find('.product-options dt') as $v) { echo str_replace('*','', $v->text()).' '; echo $v->next(); } The next element is a dd, but echo next returns nothing. How do I get the next element object? I need to get the values for dt and dd within every dl, but dd is a select element with multiple values I need.

duzun commented 8 years ago

What you need is acrtually nextElementSibling() method that I've just implemented. I couldn't use the name next() because it is part of Iterable interface and has a different meaning there.

Note: There is also a :next pseudo-selector which enables you to fetch next sibling using find('.product-options dt:next').