"; $root_element = $config['table_name'].""; //fruits $xml .= "<$root_element>"; $sql = "SELECT * FROM ".$config['table_name']; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } if(mysql_num_rows($result)>0) { while($result_array = mysql_fetch_assoc($result)) { //loop through each key,value pair in row $xml .= "<{$result_array['type']}> {$result_array['path']} "; //$key holds the table column name } } $xml .= ""; //send the xml header to the browser header ("Content-Type:text/xml"); //output the XML data echo $xml; ?>