<?php

header(“Content-type: text/xml”);

$host = “localhost”;
$user = “root”;
$pass = “”;
$database = “joom-gis”;

$linkID = mysql_connect($host, $user, $pass) or die(“Could not connect to host.”);
mysql_select_db($database, $linkID) or die(“Could not find database.”);

$query = “SELECT * FROM jos_users  where id= 62”;

$resultID = mysql_query($query, $linkID) or die(“Data not found.”);

$xml_output = “<?xml version=\”1.0\”?>\n”;
$xml_output .= “<entries>\n”;

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= “\t<entry>\n”;
$xml_output .= “\t\t<registerDate>” . $row[‘registerDate’] . “</registerDate>\n”;
$xml_output .= “\t\t<username>” . $row[‘username’] . “</username>\n”;
$xml_output .= “\t\t<email>” . $row[’email’] . “</email>\n”;
$xml_output .= “\t\t<phone>” . $row[‘phone’] . “</phone>\n”;
// Escaping illegal characters
$row[‘username’] = str_replace(“&”, “&”, $row[‘username’]);
$row[’email’] = str_replace(“<“, “<“, $row[’email’]);
$row[‘phone’] = str_replace(“>”, “&gt;”, $row[‘phone’]);
$row[‘country’] = str_replace(“\””, “&quot;”, $row[‘country     ‘]);
$xml_output .= “\t\t<usertype>” . $row[‘usertype’] . “</usertype>\n”;
$xml_output .= “\t</entry>\n”;
}

$xml_output .= “</entries>”;

echo $xml_output;

?>

http://www.kirupa.com/web/mysql_xml_php.htm