note 97970 modified in class.domelement by visualmind
| From: | visualmind@php.net | Date: | Wed, 19 May 2010 09:19:23 +0000 |
| Subject: | note 97970 modified in class.domelement by visualmind | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169396@lists.php.net to get a copy of this message | ||
Another version of patrick smith's "innerHTML" code: This shortens the foreach loop
down to one statement by taking advantage of the "ownerDocument" property of the DOMNode.
<?php
$innerHTML = '';
$doc = new DOMDocument();
$doc->loadHTMLFile($filepath);
$elem = $doc->getElementById($elem_id);
// loop through all childNodes, getting html
foreach ($elem->childNodes as $child) {
$innerHTML .= $child->ownerDocument->saveXML($child);
}
?>
--was--
Another version of patrick smith's "innerHTML" code: This shortens the foreach loop
down to one statement by taking advantage of the "ownerDocument" property of the DOMNode.
<?php
$innerHTML = '';
$doc = new DOMDocument();
$doc->loadHTMLFile($filepath);
$elem = $doc->getElementById($elem_id);
// loop through all childNodes, getting html
foreach ($elem->childNodes as $child) {
$innerHTML .= $child->ownerDocument->saveHTML($child);
}
?>
http://php.net/manual/en/class.domelement.php