First off, I’m a really a graphic designer who’s fumbling his way through this problem via some very useful tutorials on this site, my knowledge of php, xml and actionscript is extremely limited, although I can cut and paste like a demon.
I have a flash movie that is pulling content from an xml file. The xml file is generated via a php file that is pulling data from a mysql database, which is updated via the Joomla! cms. So the process sort of goes like this: cms-mysql-php-xml-flash.
The problem is that the xml file is full of ‘broken’ tags like
<p>
which used to be the
<p>
tag, and my xml once outputted in flash lacks any style or formatting. I know these tags would usually break the xml but I’m using the CDATA tag in the php file. Because I’m getting this data from a database via a cms, the database dictates how the xml file is set up. So my xml is outputted like this:
<entries>
<entry>
<title>Contact</title>
<text>
<p>Magnus es, domine, et laudabilis valde: magna virtus tua, et sapientiae tuae non est numerus.</p> etc etc...
</text>
</entry>
</entries>
So the ‘text’ node will invariably be full of html tags and will be displayed as a block of text made up of paragraphs etc.
Is there any way to solve this problem or an easier way to get data from a database into flash? Have I dug myself into a huge hole?
Here’s the php file if that helps:
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "user";
$pass = "pass";
$database = "db";
$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 id DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>
";
$xml_output .= "<entries>
";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= " <entry>
";
$xml_output .= " <title>" . $row['title'] . "</title>
";
// Escaping illegal characters
$row['introtext'] = str_replace("&", "&", $row['introtext']);
$row['introtext'] = str_replace("<", "<", $row['introtext']);
$row['introtext'] = str_replace(">", ">", $row['introtext']);
$row['introtext'] = str_replace("\"", """, $row['introtext']);
$xml_output .= " <text><![CDATA[" . $row['introtext'] . "]]></text>
";
$xml_output .= " </entry>
";
}
$xml_output .= "</entries>";
echo $xml_output;
?>
Any advice would be appreciated!
Thanks,
Matt