Return to Snippet

Revision: 1492
at October 11, 2006 11:35 by NexusRex


Initial Code
if ($num != 0) {

 $file= fopen("results.xml", "w");

 $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
";

 $_xml .="<site>
";

 while ($row = mysql_fetch_array($result)) {

 if ($row["pageTitle"]) {

 $_xml .="\t<page title=\"" . $row["pageTitle"] . "\">
";

 $_xml .="\t\t<file>" . $row["pageLink"] . "</file>
";
$_xml .="\t</page>
";
 } else {

 $_xml .="\t<page title=\"Nothing Returned\">
";
$_xml .="\t\t<file>none</file>
";

 $_xml .="\t</page>
";
 } }

 $_xml .="</site>";

 fwrite($file, $_xml);

 fclose($file);

 echo "XML has been written.  <a href=\"results.xml\">View the XML.</a>";

 } else {

 echo "No Records found";

 } ?>

Initial URL
http://builder.com.com/5110-6388-5055276.html

Initial Description

                                

Initial Title
Create XML file and populate with data from mySQL

Initial Tags
mysql, xml

Initial Language
PHP