Created
November 17, 2011 18:54
-
-
Save komlenic/1374083 to your computer and use it in GitHub Desktop.
Get innerHTML of a php DOMElement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
?> |
Awesome!
Thank's
Hi, it's good and working but if there is any ol tag then it is being removed from there
classic php, keeping it awkward. thanks for this
e: use saveHTML. saveXML will produce things like <div/>
Thank you all
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lovely code..!! the only code that actually worked to get the child node markup. Thanks a million.