So I'm making an AJAX live search but I need the xml document to be updated on the completion of a form. I am using SimpleXml to edit it. Here is the xml I am trying to add to. (called search.xml)
<pages>
<link>
<title>test</title>
<url>their sites go here</url>
</link>
<link>
<title>testdos</title>
<url>their sites go here</url>
</link>
<link>
<title>testtres</title>
<url>their sites go here</url>
</link>
<link>
<title>testagain</title>
<url>their sites go here</url>
</link>
</pages>
Here is the php that is supposed to add to it, it is within an "if(isset('submit'))".
//the info that is added
$xml_add = "<title>testcuartro</title> <url>www.url.org</url>";
//loads the document
$xml_file = simplexml_load_file("search.xml");
// adds the info
$xml_file->pages->addChild("link","$xml_add");
// saves the changes
echo $xml_file->asXML("search.xml");
When I run this code, there is no change to the XML document. Any help would be greatly appreciated.