note 86803 added to class.domelement

From: Date: Tue, 04 Nov 2008 16:14:12 +0000
Subject: note 86803 added to class.domelement
Groups: php.notes 
Request: Send a blank email to php-notes+get-146123@lists.php.net to get a copy of this message
Although it may be preferable to use the dom to manipulate elements, sometimes it's useful to actually get the innerHTML from a document element (e.g. to load into a client-side editor). To get the innerHTML of a specific element ($elem_id) in a specific html file ($filepath): $innerHTML = ''; $doc = new DOMDocument(); $doc->loadHTMLFile($filepath); $elem = $doc->getElementById($elem_id); // loop through all childNodes, getting html $children = $elem->childNodes; foreach ($children as $child) { $tmp_doc = new DOMDocument(); $tmp_doc->appendChild($tmp_doc->importNode($child,true)); $innerHTML .= $tmp_doc->saveHTML(); } ---- Server IP: 209.41.74.194 Probable Submitter: 164.82.84.3 ---- Manual Page -- http://www.php.net/manual/en/class.domelement.php Edit -- https://master.php.net/note/edit/86803 Del: integrated -- https://master.php.net/note/delete/86803/integrated Del: useless -- https://master.php.net/note/delete/86803/useless Del: bad code -- https://master.php.net/note/delete/86803/bad+code Del: spam -- https://master.php.net/note/delete/86803/spam Del: non-english -- https://master.php.net/note/delete/86803/non-english Del: in docs -- https://master.php.net/note/delete/86803/in+docs Del: other reasons-- https://master.php.net/note/delete/86803 Reject -- https://master.php.net/note/reject/86803 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146123) next »