Save generated XML to the server

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
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Save generated XML to the server

Post by elHelgo »

I want to be able to generate an XML document, and then save it as a .xml file to the server. In general, here's what I'm trying to produce:

Code: Select all

$xml_code = '<?xml version="1.0" encoding="UTF-8"?>';
$xml_code = $xml_code . '<gallery>';
$xml_code = $xml_code . '<album id="bouldering" title="Bouldering" lgPath="comphotos/bouldering/">';
$xml_code = $xml_code . '<img src="125Bouldering04.jpg" caption="This where your photo caption would be" />';
... and so on ...

After the xml is complete, I want to be able to save $xml_code as images.xml and have it uploaded to my server.

Many thanks are in advance for helping me solve my problem.

Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

elHelgo wrote:and have it uploaded to my server
where's the php script running? Another server?
Maybe you're looking for http://de3.php.net/file_put_contents
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Sort of ...

Post by elHelgo »

That's exactly what I'm looking for except that I'm running version 4.3.2. I need something that will do that, but could work on an older version.

The php script will be running on the same server as the .xml file. I think I know how to save it to the server, I just need to know how to create the .xls file and write the xml data to it.

Thanks for the quick response though.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The manual page linked by volka has user comments that should give details of how to use the function in older versions of PHP..
Post Reply