0

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

2
  • what were you searching for that gave you no solution? solutions to this are easily available. search on google for php write text to file. the first result is spot on. Commented Feb 17, 2016 at 16:06
  • ok but i thought for xml that was different . Thanks Commented Feb 17, 2016 at 16:28

1 Answer 1

1

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() );
Sign up to request clarification or add additional context in comments.

1 Comment

Sometimes developpers looks for something difficult... Often, coding is more simple that i can imagine Thanks a lot guy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.