diff --git a/src/PHPHtmlParser/Selector.php b/src/PHPHtmlParser/Selector.php index e0e1ac73..6910f3d6 100644 --- a/src/PHPHtmlParser/Selector.php +++ b/src/PHPHtmlParser/Selector.php @@ -6,6 +6,7 @@ use PHPHtmlParser\Dom\InnerNode; use PHPHtmlParser\Dom\LeafNode; use PHPHtmlParser\Exceptions\ChildNotFoundException; +use Countable; /** * Class Selector @@ -168,7 +169,9 @@ protected function parseSelectorString($selector) protected function seek(array $nodes, array $rule, array $options) { // XPath index - if (count($rule['tag']) > 0 && + if ($rule['tag'] instanceof Countable && + count($rule['tag']) > 0 && + $rule['key'] instanceof Countable && count($rule['key']) > 0 && is_numeric($rule['key']) ) {