I am trying to append to an existing XML document using DOM. Here's my code:
$xmlfile = "library.xml";
$doc = domxml_open_file($xmlfile);
$bookNode = $doc->create_element("book");
$bookNode = $root->append_child($bookNode);
$titleNode = $doc->create_element("title");
$titleNode = $bookNode->append_child($titleNode);
$authorNode = $doc->create_element("author");
$authorNode = $bookNode->append_child($authorNode);
$titleText = $doc->create_text_node("Clear Mountain Water");
$authorText = $doc->create_text_node("Rob Johnson");
$titleText = $titleNode->append_child($titleText);
$authorText = $authorNode->append_child($authorText);
$doc->dump_file("library.xml",false,true);
?>
I open library.xml, create new nodes, and then perform dump_file() to the same XML file. I get no errors, but library.xml is not changed. If I change the file name parameter in dump_file to a document that doesn't exist that works fine. I've seen examples that work exactly the same.
Thanks to whoever can help.