This will give you outerHTML, not innerHTML, but you can easily remove the extra DIV tags from both ends.
Working example:
$xpath = new DOMXPath( @DOMDocument::loadHTML($the_html_code) ) ;
$domElement = $xpath->evaluate("//div[@id='ID_of_the_div']")->item(0) ;
$outerHTML = $domElement->ownerDocument->saveXML($domElement) ;
source
share