create xml document from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deepcover
Forum Newbie
Posts: 1
Joined: Sat Feb 06, 2010 1:48 am

create xml document from php

Post by deepcover »

Hi

I know that this question have been asked many times before, but I can't seem to find the exact answer for my need.

What is the best way to create a xml document from php?

I have read about several solutions, some does not actually create the file but only shows the xml code on the screen, I think I need a fysical xml file because i need to use the data in actionscript later on.
Then there's DOM which I can't figure out if I am supposed to install on my server(not my own server, just some random standard web server) or how it is used.

Hope someone can clear things up for me.

Thanks
Deepcover
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: create xml document from php

Post by Grizzzzzzzzzz »

if you're getting the entire XML written on the screen, then you're already 99% of the way there.


Simply take the string that's being outputted, and write it to a file

Code: Select all

 
$myFile = "test.xml";
$fh = fopen($myFile, 'w');
$stringData = "alllllllll your XML";
fwrite($fh, $stringData);
fclose($fh);
 
Post Reply