时间:2021-07-01 10:21:17 帮助过:3人阅读
$dom = new DOMDocument('1.0', 'UTF-8');$dom->formatOutput = true;$filename = $this->appurl.$this->modeldir."/template/".$lang."/eval_tytakg.xml";$dom ->load($filename);//先?除$xpath = new domxpath($dom);$olddata = $xpath->query("/data")->item(0);if($olddata){ $olddata->parentNode->removeChild($olddata); $dom->preserveWhiteSpace = false; $dom->load($filename); $dom->save($filename);}
木有人回覆?我自己把帖子?起?
我的做法是如果文件存在,先UNLINK,然后再创建新文件写入需要的内容