This script creates a new XML file with the original data and doesn’t have the updates.
<?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;
?>
The permissions are right because the file format is modified and the file is saved with a new date.
It looks like you are missing some append statements, namely: