Witam w php i mysql jestem dobry lecz XML to dla mnie magia xP
Prosze o wyjaśnienie jak w xmlu mozna wyciągnąć dane z bazy mysql
Z góry dzieki za pomoc
if ($num != 0) { $file= fopen("results.xml", "w"); $_xml ="<?xml version="1.0" encoding="UTF-8" ?>rn"; $_xml .="<site>rn"; while ($row = mysql_fetch_array($result)) { if ($row["pageTitle"]) { $_xml .="t<page title="" . $row["pageTitle"] . "">rn"; $_xml .="tt<file>" . $row["pageLink"] . "</file>rn";$_xml .="t</page>rn"; } else { $_xml .="t<page title="Nothing Returned">rn";$_xml .="tt<file>none</file>rn"; $_xml .="t</page>rn"; } } $_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"; } ?>
CREATE TABLE x (doc VARCHAR(150)); INSERT INTO x VALUES (' <book> <title>A guide to the SQL standard</title> <author> <initial>CJ</initial> <surname>Date</surname> </author> </book> '); INSERT INTO x VALUES (' <book> <title>SQL:1999</title> <author> <initial>J</initial> <surname>Melton</surname> </author> </book> ');
mysql> SELECT EXTRACTVALUE(doc,'/book/author/initial') FROM x; +------------------------------------------+ | EXTRACTVALUE(doc,'/book/author/initial') | +------------------------------------------+ | CJ | | J | +------------------------------------------+ 2 rows IN SET (0.01 sec)