eriknv Posted July 3, 2007 Share Posted July 3, 2007 I want to export my addresses to a .xml file. I want to call it like this: www.mydomain.com/thefile.xml. Does anyone know if this is possible? And I wants that it updates automatically. Sorry but my English is not so well. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
Guest Million68 Posted July 3, 2007 Share Posted July 3, 2007 Hm you can try this. It connects to your database picks up the information you want and put it in a xml file. It dont work automatically, you have to start the php file but it´s a way to solve your problem. <?php function MySQLtoXML($ResultPointer, $Tabelle, $rowname = "Row") { $SimpleXMLElement = new SimpleXMLElement("<$Table></$Table>"); while($row = mysql_fetch_object($ResultPointer)) { $rows = $SimpleXMLElement->addChild($rowname); foreach($row as $column => $Value) { $rows->$column = $Value; } } return $SimpleXMLElement->asXML(); } $DatabaseHost = "localhost"; $DatabaseUser = "root"; $DatabasePassword = ""; $Database = "mydatabase"; $Tabelle = "adress"; $DatabasePointer = mysql_connect($DatabaseHost, $DatabaseUser, $DatabasePassword); mysql_select_db($Database, $DatabasePointer); $ResultPointer = mysql_query("SELECT * FROM $Table"); echo MySQLtoXML($ResultPointer, $Table); ?> It should look like this: ?xml version="1.0"?> <Adress> <Row> <ID>1</ID> <Name>Brian Jackson</Name> <Adress>hereandthere 1</Adress> <zipcode>38491</zipcode> <city>Samplecity</city> <Land>Somewhere over the Rainbow</Land> </Row> <Row> <ID>2</ID> <Name>Sammy Smartypants</Name> <Adress>under the Bridge 249</Adress> <zipcode>66666</zipcode> <city>Atlantis D.C.</city> <Land>Atlantis</Land> </Row> </Adress> I think that should work. Greets Million68 The unofficial Cubecart-Ambassador for Germany Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.