Jump to content

PHP to parse DOM and setInnerHTML?


notanoob

Recommended Posts

$doc = DOMDocument::loadHTMLFile("test.html");

$ele = $doc->getElementById('di');

//missing ability to setinnerhtml,

//something like $ele->setInnerHTML("<div>sdfsdfdsf<b>dsfdsF</b></div>");

//or

//something like setInnerHTML($ele, "<div>sdfsdfdsf<b>dsfdsF</b></div>");

echo $doc->saveHTML();

 

Does anyone know a way to implement a setInnerHTML type function to remove all the children of a Dom Element and replace them with new children based on a string of HTML?  (I don't want to use createElement and all that directly, obviously, but some suggestion of how to use that inside the setInnerHTML function would be nice)

Link to comment
https://forums.phpfreaks.com/topic/94821-php-to-parse-dom-and-setinnerhtml/
Share on other sites

  • 3 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.