Public paste
XML 1
By: Xmoo | Date: Sep 5 2008 11:51 | Format: PHP | Expires: never | Size: 535 B | Hits: 1204

  1. <?php
  2.  
  3. $db=mysql_connect("localhost","root");
  4. mysql_select_db("xml",$db);
  5.  
  6.  
  7. $xml = "<?xml version='1.0' encoding='ISO-8859-1'?>";
  8. $xml.= "<tutorgroepen>";
  9.  
  10. $sql=mysql_query("SELECT * FROM tutorgroep");
  11. while (list($id, $tutor) = mysql_fetch_row($sql)){
  12.    $xml.= "<groep>";
  13.    $xml.= "<groepcode>$id</groepcode>";
  14.    $xml.= "<tutor>$tutor</tutor>";
  15.    $xml.= "</groep>";
  16. }
  17. $xml.= "</tutorgroepen>";
  18.  
  19. $file=fopen("xm1.xml","w");
  20. fputs($file,$xml);
  21. fclose($file);
  22.  
  23. header ("content-type: text/xml");
  24. echo $xml;
  25. ?>