php-html-parser
php-html-parser copied to clipboard
Find does not work with multiple attributes
$dom->find(…) does not work with a CSS selector with multiple attributes.
Example:
$testDom = new Dom();
$testDom->loadStr('<div><input type="checkbox" name="color" value="blue"><input type="checkbox" name="color" value="red"></div>');
$allCheckboxes = $testDom->find('input[name="color"]');
echo count($allCheckboxes); // 2 → that is fine
$blueCheckbox = $testDom->find('input[name="color"][value="blue"]', 0);
echo is_null($blueCheckbox); // true → Not good! I would expect the checkbox with value "blue" here.
Workaround: One could select just for the value $testDom->find('input[value="blue"]', 0); but this could of course find results with unwanted name-attributes too.