好的,是以你的解決方案.
對于DIV:
This is not working!
這樣做:
$dom = new DOMDocument("1.0", "utf-8");
$dom->loadHTMLFile('YourFile.html');
$div = $dom->getElementById('divID');
echo $div->textContent;
$div->setAttribute("name", "yesItWorks");
?>
隻要你傳遞一個精心制作的XML或XHTML内容,就可以在沒有檔案的情況下工作
$dom->loadHTMLFile('YourFile.html');
到你的
$dom->loadHTML($html);
哦是的,當然,改變内容(完整性):
$div->removeChild($div->firstChild);
$newText = new DOMText('Yes this works!');
$div->appendChild($newText);
然後你可以再次回聲它或什麼的.