Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create and Save XML file to Server Using PHP

Tags:

php

xml

I'm using PHP to extract data from a MySQL database. I am able to build an XML file using DOM functions. Then using echo $dom->saveXML(); , I am able to return the XML from an AJAX call. Instead of using AJAX to get the XML, how would I save the XML file to a spot on the server? Thanks

like image 692
Casey Avatar asked Dec 03 '22 15:12

Casey


1 Answers

Use the DOMDocument::save() method to save the XML document into a file:

$dom->save('document.xml');
like image 138
Gumbo Avatar answered Dec 17 '22 12:12

Gumbo