Jump to content

Export addresses by XML


eriknv

Recommended Posts

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. :sourcerer: Thanks a lot.

Link to comment
Share on other sites

Guest Million68

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...