<?php $html = '<!doctype html> <html> <head> <title>test</title> </head> <body> <a id="1"> <b>value1</b> <b>value2</b> </a> <a id="2"> <b>value1</b> </a> </body> </html>'; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXpath($doc); $nodes = $xpath->query("//b[contains(., 'value1')] | //b[contains(., 'value2')]"); $parent_id = $nodes->item(0)->parentNode->getAttribute("id"); echo $parent_id;
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`