有没有办法将源html添加到DOMElement?这样的东西
$trElement->appendSource("<a href='?select_user=4'>Username</a>");
它将解析该片段,然后附加它.
解决方法
你在找
– DOMDocumentFragment::appendXML
— Append raw XML data
手册示例:
$doc = new DOMDocument(); $doc->loadXML("<root/>"); $f = $doc->createDocumentFragment(); $f->appendXML("<foo>text</foo><bar>text2</bar>"); $doc->documentElement->appendChild($f); echo $doc->saveXML();