2

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.

Ray Mayo
  • 41
  • 6
  • When you say "nothing happens", what precisely do you mean: the XML appears unchanged? or the page appears completely blank? In the latter case, you probably have an error, with PHP configured to log but not display errors. See http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851 – IMSoP Apr 03 '17 at 15:07
  • When I run the code, the XML document doesn't change – Ray Mayo Apr 04 '17 at 12:55

0 Answers0