此腳本創建一個包含原始數據的新XML文件,但沒有更新。PHP腳本保存xml而不更新
<?php
$dom = new DOMDocument();
$dom->load('communities.xml');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
// get document element
$root = $dom->documentElement;
$name = $dom->createElement("NAME");
$nameText = $dom->createTextNode("Hobbies");
$name->appendChild($nameText);
$community = $dom->createElement('COMMUNITY');
$community->appendChild($name);
$dom->save('communities.xml');
$tidy_options = array(
'input-xml' => true,
'output-xml' => true,
'indent' => true,
'wrap' => false,
);
$tidy = new tidy();
$tidy->parseFile('communities.xml', $tidy_options);
$tidy->cleanRepair();
echo $tidy;
return;
?>
權限是正確的,因爲文件格式被修改,文件被保存一個新的日期。
究竟是什麼問題呢? –