mysql to xml

  • Creatore Discussione Creatore Discussione salvodj
  • Data di inizio Data di inizio

salvodj

Nuovo Utente
16 Feb 2008
7
0
0
ciao ragazzi
da stamattina che sto facendo prove su i miei script in flash e xml. ho trovato su internet un tutorial che converte il contenuto delle tabelle mysql in xml ma il file xml che mi genera non è come quello che mi serve

xml originale.

- <rss>
- <channel>
- <item id="1">
<title>capodanno</title>
<pubDate>31/12/2007</pubDate>
<image>images.jpg</image>
<description>provaaaaaaaaaaaaaaaaaaaaaaaaaa</description>
<link>http://www.salvodj.com</link>
</item>
</channel>
</rss>

script php.

<?php
header("Content-type: text/xml");

$host = "localhost";
$user = "root";
$pass = "";
$database = "gestione";

$linkID = mysql_connect($host,$user,$pass) or die ("Could not connect to host.");
mysql_select_db($database,$linkID) or die ("Could not find database.");


$query = "SELECT * from news ORDER BY id DESC";
$resultID = mysql_query($query,$linkID) or die ("Data not found");

$xml_output = "<?xml version =\"1.0\"?>\n";
$xml_output = "<rss>\n";

for ($x = 0; $x < mysql_num_rows($resultID); $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<channel>\n";
$xml_output .= "\t<item id=\"" . $row['id'] . "\"/>";
$xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
$xml_output .= "\t\t<pubDate>" . $row['pubDate'] . "</pubDate>\n";
$xml_output .= "\t\t<image>" . $row['image'] . "</image>\n";
$xml_output .= "\t\t<description>" . $row['description'] . "</description>\n";
$xml_output .= "\t\t<link>" . $row['link'] . "</link>\n";
$xml_output .= "\t</channel>\n";
}

$xml_output.= "</rss>";

echo $xml_output;
?>


quello che mi esce da il php è questo.

- <rss>
- <channel>
<item id="1" />
<title>capodanno</title>
<pubDate>31/12/2007</pubDate>
<image>images.jpg</image>
<description>provaaaaaaaaaaaaaaaaaaaaaaaaaa</description>
<link>http://www.salvodj.com</link>
</channel>
</rss>


ho provato e riprovato , ho fatto una ricerca anche su internet ma niente da fare
magari se mi potete aiutare grazie.
 

Discussioni simili