我的英语不好:")) 请帮帮我
<?php
$htmldiv= //it is html ,and it is not XML.
"<div class=\"MyClass\" id=\"MyID\">
ABC <hr>
<div></div>
</div>";
$html=
"<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'>
<title>TEST</title>
</head>
<body></body>
</html>";
$dom = new DOMDocument();
$dom->loadHTML($html);
$elementlist = $dom->getElementsByTagName("body");
$body=$elementlist->item(0);
$body->appendChild( $htmldiv ); // it is error. i want to append $htmldiv into $body and how can i do ????? :'(
echo $dom->saveHTML();
?>
我不能使用 createDocumentFragment 。我能怎么做??
$fragment = $dom->createDocumentFragment();
$fragment->appendXML($htmldiv);
$body->appendChild( $fragment ); // it is error.