I have document from which I want to extract specific div with it\'s untouched content. I do:
$dom = new DOMDocument(); $dom->loadHTML($string);//that\'s
Just pass the node to the DOMDocument::saveHTML method:
$htmlString = $dom->saveHTML($xpath_resultset->item(0));
This will give you a string representation of that particular DOMNode and all its children.