I have a whole HTML string that is being evaluated using PHPDom and it's working perfectly, except I don't know how to do this one thing that seems really basic. I need to select an HTML element via XPath and have that element's content returned as a string. So far, this is what I have. Can anyone point me in the right direction as to how to proceed? Thank you!
$dom = new DOMDocument();
@$dom->loadHTML($thehtml);
$xpath = new DOMXPath($dom);
$elementhtml = $xpath->evaluate('//*[@id="elementid"]');
var_dump($elementhtml);
die();
So basically, I need $elementhtml to be the contents of the "elementid" HTML element.