Skip to content

Instantly share code, notes, and snippets.

@wenpeng
Forked from komlenic/DOMElement.innerHTML.php
Created October 26, 2015 10:12
Show Gist options
  • Save wenpeng/abd2385810d5d7aad742 to your computer and use it in GitHub Desktop.
Save wenpeng/abd2385810d5d7aad742 to your computer and use it in GitHub Desktop.
Get innerHTML of a php DOMElement
<?php
// See http://www.php.net/manual/en/class.domelement.php#101243
function get_inner_html( $node ) {
$innerHTML= '';
$children = $node->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveXML( $child );
}
return $innerHTML;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment