llaid
llaid

Reputation: 85

Save XML to the server a file generated by PHP

After some searches on the web and some tests, i can't find the solution and need your help

From a php script, i create a XML output :

$xml = new SimpleXMLElement($string);
//some code
echo $xml->asXML();

I Would like to create a file contain the XML and save on my server by using PHP.

Thanks for your help

Upvotes: 0

Views: 1578

Answers (1)

Professor Abronsius
Professor Abronsius

Reputation: 33823

if echo $xml->asXML() displays the xml then I guess you could use file_put_contents or other similar function. ie:

$filepath='/path/to/directory/filename.xml';
file_put_contents( $filepath, $xml->asXML() );

Upvotes: 1

Related Questions