// ----------------------------------------------------------------------
// Erstmal Initialisieren - Anpassen -
// ----------------------------------------------------------------------
$dbHost = "
localhost";
$dbUser = "root";
$dbPassword = "";
$dbName = 'XMLDB';
$dbtable = $_POST["Mytable"];
// ----------------------------------------------------------------------
// Dann die Verbindung pruefen
// ----------------------------------------------------------------------
if (!mysql_connect($dbHost, $dbUser, $dbPassword)) {
echo 'Keine Verbindung zur Datenbank möglich';
exit;
}
// ----------------------------------------------------------------------
// Und nun alle Spalten der Tabelle in das
XML-Dokument schreiben
// ----------------------------------------------------------------------
if(isset( $dbtable ))
{
header("Content-Type: application/
xml");
mysql_select_db($dbName);
$result = mysql_query("SELECT * FROM $dbtable");
$XMLDoc = new SimpleXMLElement
("<?
xml version='1.0' standalone='yes'?><$dbtable></$dbtable>");
while($dbrow = mysql_fetch_object($result))
{
$xmlrow = $XMLDoc->addChild("row");
foreach($dbrow as $Spalte => $Wert)
$xmlrow->$Spalte = $Wert;
}
echo $XMLDoc->asXML();
}
// ----------------------------------------------------------------------
// bleibt noch das Aufraumen
// ----------------------------------------------------------------------
mysql_free_result($result);
?>
// ----------------------------------------------------------------------
// Da isses, das Ende
// ----------------------------------------------------------------------