\n"; if ($xslt_file) $XML .= "\n"; // root node $XML .= "\n"; // rows while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $XML .= "\t\n"; $i = 0; // cells foreach ($row as $cell) { // Escaping illegal characters - not tested actually ;) $cell = str_replace("&", "&", $cell); $cell = str_replace("<", "<", $cell); $cell = str_replace(">", ">", $cell); $cell = str_replace("\"", """, $cell); $col_name = mysql_field_name($result,$i); // creates the "contents" representing the column $XML .= "\t\t<" . $col_name . ">" . $cell . "\n"; $i++; } $XML .= "\t\n"; } $XML .= "\n"; // output the whole XML string echo $XML; ?>