ID:               44762
 Comment by:       roly426 at gmail dot com
 Reported By:      xwisdom at yahoo dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: Windows XP
 PHP Version:      5.2.5
 New Comment:

I was trying to use the above method to get the innerHTML in an HTML
document but sine these functions are designed for XML, some HTML will
get changed. Example, <br /> will get changed to <br>


Previous Comments:
------------------------------------------------------------------------

[2008-11-04 16:16:17] patrick at patricksmith dot org

In the meantime, here's a utility function that you may find helpful:

$innerHTML = '';
$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();
}

------------------------------------------------------------------------

[2008-04-17 14:40:05] xwisdom at yahoo dot com

Description:
------------
I would like to request that a innerHTML property (or method) be added
to DOMElement class. This would make it so much easier to retrieve and
set the html or xml content of a node.

Right now we have to use fragments with several lines of to get the job
done. It would be so much better to be able to do it in one line of code
:)







------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44762&edit=1

Reply via email to