Is there a way of retrieving HTML (and JavaScript) contained in a div element?
$xml=new DOMDOCUMENT();
@$xml->loadHTML($htmlcontents);
$xpath=new DOMXPATH($xml);
$nodes=$xpath->query($xpath);
function getHtml($nodes) {
$result = '';
foreach ($nodes as $node) {
$result .= $node->ownerDocument->saveHtml($node);
}
return $result;
}
Source: how to get innerhtml by classname or id using php