"; if ($xslt_file or $raw) { // we produce XML header("Content-type: text/xml"); $XML = "\n"; if (!$raw) $XML .= ""; } else { // we produce HTML. All XML tags are replaced by printable entities $XML = "Don't forget to create an XSLT file ....

"; $XML .= "

\n";
   $left = "<";
   $right = ">";
 }

// root node
  $XML .= $left . "result" . $right . "\n";
// rows
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {    
  $XML .= "\t" . $left. "row" . $right . "\n";  // creates either "" or "<row>"
  $i = 0;
  // cells
  foreach ($row as $cell) {
    // Escaping illegal characters
    $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, either as XML or for display in HTML
    $XML .= "\t\t" . $left . $col_name . $right . $cell . $left . "/" . $col_name . $right ."\n";
    $i++;
  }
  $XML .= "\t" . $left. "/row" . $right . "\n";
 }

  $XML .= $left . "/result" . $right . "\n";

echo $XML;
if (!$xslt_file && !$raw) echo "
"; ?>