Hi,
I have to output xml with php for a project i am working on. So far so good til i came across CDATA.
I am new to xml with php and I'm not sure how to output it in my code.
Below is what i have but my positioning of this CDATA is completley wrong and I'm not too sure how to make it right.
$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 featured, articles
WHERE featured.case_ref= articles.article_ref";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml_output .="<caseFeatures>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .="<case>\n";
$xml_output .= "\t\t<title>"<![CDATA[<p> . $row['short_title'] . </p>]]>"</title>\n";
$xml_output .= "\t\t<asset>";
$xml_output .= "/assets/". $row['logo'] . "</asset>\n";
$xml_output .= "\t<credit><p>" . $row['credit'] . "</p></credit>\n";
$xml_output .= "\t<caselink>";
$xml_output .= "case_detail.php?article_ref=" . $row['article_ref'] . "</caselink>\n";
$xml_output .="</case>\n\n";
}
$xml_output .="</caseFeatures>";
echo $xml_output;
Any help is greatly appreciated.