Hi,
I am looking for a way to write an xml with attributes like this :
<announcements>
<news title="Groove Magazine#98/N7 CD" date="2006" image="images/news/groovethumb.jpg" hoes="images/news/groove.jpg" aside="if.mp3" buy="not for sale">
<copy>
<p>
Compilation with various artists like Henrik Schwarz, I:Cube, Steve Spacek a.o
</p>
</copy>
</news>
I now have this script, but that generates an xml my flash file cannot read. The script is :
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "joomla108";
$pass = "******l";
$database = "joomla108";
$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 jos_content ORDER BY created DESC";
$query = "SELECT FROM jos_content WHERE sectionid='1' ORDER BY sectionid DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<announcements>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<news>\n";
$xml_output .= "\t\t<date>" . $row['created'] . "</date>\n";
$xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
// Escaping illegal characters
//$row['introtext'] = str_replace("&", "&", $row['introtext']);
//$row['introtext'] = str_replace("<", "<", $row['introtext']);
//$row['introtext'] = str_replace(">", ">", $row['introtext']);
$xml_output .= "\t\t<intro>" . $row['introtext'] . "</intro>\n";
// Escaping illegal characters
//$row['fulltext'] = str_replace("&", "&", $row['fulltext']);
//$row['fulltext'] = str_replace("<", "<", $row['fulltext']);
//$row['fulltext'] = str_replace(">", ">", $row['fulltext']);
$xml_output .= "\t\t<full>" . $row['fulltext'] . "</full>\n";
$xml_output .= "\t</news>\n";
}
$xml_output .= "</announcements>";
echo $xml_output;
$printout = fopen('main.xml','w');
fwrite($printout,$xml_output);
fclose($printout);
//mail($from, $subject, $klantbericht, $additionalHeaders);
?>
The above php code generates an xml without attributes but with childes. Anybody an idea how to get php to write attributes instead of childs ?
Thx in advance !
Bart