PDA

View Full Version : Generating an XML File



alliance_studio
29 Nov 2010, 07:45 AM
I am currently working on an ordering system that requires users to add to basket, confirm their basket, add a delivery address and then place an order.

One they have placed the order, the contents of their basket along with their delivery address is saved to a MySql database. This is all done using PHP and sessions.

Now to the part I'm stuck on...

All the information about the order that is being saved to the database also needs to be compiled into an XML which will then be sent to an IP address however I have no idea on how this can be accomplished.

Any help will be greatly appreciated!

<CrGeary.com/>
29 Nov 2010, 12:06 PM
just use the php file functions: http://www.php.net/manual/en/ref.filesystem.php

<?php
$fh = fopen( 'filename.xml', 'w' ); // to create an xml file, or open an existing on with that same name;

$xml_contents = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
";

fwrite( $fh, $xml_contents );

fclose( $fh );

`i think thats right, something along those lines. I havn't written anything for files for a long time so could be a little rusty.