ameliabob Posted May 28, 2008 Share Posted May 28, 2008 I have an existing document on the server and will be updating the file based on the browser and would like to write it back to disk upon completion.I am using the "xmlDoc.load("note.xml");" that is in your example but I can't find the corresponding output statement. Where would I find this? Link to comment Share on other sites More sharing options...
Ingolme Posted May 28, 2008 Share Posted May 28, 2008 You can't write in an XML document with Javascript. You can modify the nodes before you use them for something, that's all.If you use PHP's DOMDocument you can use file_put_contents() and put the XML in the file after processing it (I've used it myself for RSS feeds). Link to comment Share on other sites More sharing options...
ameliabob Posted June 3, 2008 Author Share Posted June 3, 2008 I have an existing document on the server and will be updating the file based on the browser and would like to write it back to disk upon completion.I am using the "xmlDoc.load("note.xml");" that is in your example but I can't find the corresponding output statement. Where would I find this?So, if I understand you correctly, I load an XML document then if I process it and change some values I use the file_put_content. But do I just point to the DOM object to put it out? Link to comment Share on other sites More sharing options...
Ingolme Posted June 3, 2008 Share Posted June 3, 2008 You use the saveXML() method of the DOMDocument object to convert the XML to a string and then put it back into the file you extracted it from.Well, you do it like this: $xmlDoc = new DOMDocument();$xmlDoc->load("file.xml");// Perform some XML DOM modificationsfile_put_contents("file.xml",$xmlDoc->saveXML()); Link to comment Share on other sites More sharing options...
boen_robot Posted June 7, 2008 Share Posted June 7, 2008 Note that a more efficient alternative is to use DOMDocument::save(), like: $xmlDoc = new DOMDocument();$xmlDoc->load("file.xml");// Perform some XML DOM modifications$xmlDoc->save('file.xml'); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.