且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单的HTML Dom解析器:如何插入元素

更新时间:2022-03-12 22:25:31

查看源代码后,我发现解决方法是使用

After looking at the source code, I found that the way to go about it is to use

$var = "some JS stuff";
$e = $htmlDOM->find("body", 0);
$e->outertext = $e->makeup() . $e->innertext . $var . '</body>';

也就是说,未记录的makeup()函数将构建标记和任何关联的文本/代码.

That is, the undocumented makeup() function will build the tag and any associated text/code.