PDA

View Full Version : Xml-php


Fuego
11-24-2004, 07:31 PM
Trying to create a xml with PHP, i just spent the whole day finding this
out but I cant find the thing Im doing wrong...

This code will run, it does validate with no problems but
when i run this im seeing a blank page with the rss code
in the source of the page.



<?php
$rss .= "<rss version=\"1.0\">\n";
$rss .= "<channel>\n";

if(!$dbconnect = mysql_connect(xxxxxxxxx)) {
echo "Connection failed to the host 'localhost'.";
exit;
} // if
if (!mysql_select_db(xxxxxxxxxx)) {
echo "Cannot connect to database 'test'";
exit;
} // if

$table_id = 'mednet.doc';

/* Make database query */
$query = "SELECT * FROM $table_id where teksttype = 'Nieuws Bericht' limit 1";
$dbresult = mysql_query($query, $dbconnect);

while($logs=mysql_fetch_array($dbresult)) {

$logs = str_replace("<", "&lt;", $logs);
$logs = str_replace(">", "&gt;", $logs);
$logs = str_replace("\\", "", $logs);

$rss .= "<item>\n";
$rss .= "<title>".$logs['naam']."</title>\n";
$rss .= "<description><![CDATA[".$logs['inhoud']."]]></description>\n";
$rss .= "</item>\n";

} $rss .= "</channel>\n";
$rss .= "</rss>";
echo($rss);
?>

gsnedders
11-24-2004, 08:39 PM
The XML prologue isn't there...

Alex Vincent
11-25-2004, 02:10 AM
Said prologue isn't strictly necessary.

Is it blank in IE? Is it blank in Mozilla (Firefox/App Suite)? Is it blank in Opera?

What does View Source say?

Fuego
11-25-2004, 09:20 AM
It gives a blank page, in mozilla and ie
This is the sourcecode of the output


<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="1.0">
<channel><item>
<title>Post 1</title>

<description><![CDATA[
Content post 1
]]></description>
</item>
</channel>
</rss>

Alex Vincent
11-26-2004, 04:41 AM
It's well-formed, but I see no <?xml-stylesheet ?> tag to tell browsers how to render it.