notanoob Posted March 7, 2008 Share Posted March 7, 2008 $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) Quote Link to comment Share on other sites More sharing options...
notanoob Posted March 7, 2008 Author Share Posted March 7, 2008 the ability to do this could revolutionize web programming! This is why they didn't include it in PHP standard--or any other serverside language--because it would render the need for templating engines useless! Quote Link to comment Share on other sites More sharing options...
Veehmot Posted June 22, 2008 Share Posted June 22, 2008 You could use replaceChild() method to replace the node with another one. And that one will be generated by loadHTML() method. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.