'; $xml .= ''; $xml .= 'La tunisie medicale : '.$rubtitle.''; $xml .= 'http://www.latunisiemedicale.com/'; $xml .= 'La tunisie medicale : '.$rubtitle.''; $xml .= ''; $xml .= ' La tunisie medicale : '.$rubtitle.''; $xml .= ' http://www.latunisiemedicale.com/rss/logo.gif'; $xml .= ' http://www.latunisiemedicale.com/'; $xml .= ''; // boucle item while($row=mysql_fetch_assoc($res)){ $description=''; $titre=clean_up($row["Titre_article"]); $lien="http://www.latunisiemedicale.com/article-medicale-tunisie.php?article=".$row["ID_article"]."&Codelang=".$lang; $reqauteur=mysql_query("select Nom_aut from auteur,auteur_article where auteur.ID_aut=auteur_article.ID_auteur and ID_article='".$row["ID_article"]."' order by Order_auteur_article and auteur_article.etat=1")or die(mysql_error()); $countt=mysql_num_rows($reqauteur); while($resauteur=mysql_fetch_array($reqauteur)){ $description.= $resauteur["Nom_aut"]; if($count!=($countt-1)) $description.= ", "; } $description = clean_up($description) ; $mois=$row["Mois_revue"]; if(count($mois)<2) $mois="0".$row["Mois_revue"]; $date=$res["Annee_volume"]."-".$mois."-00"; $date2=date("D, d M Y H:i:s", strtotime($date)); $xml .= ''; $xml .= ''.$titre.''; $xml .= ''.$lien.''; $xml .= ''.$date2.' GMT'; $xml .= ''.$description.''; $xml .= ''; } // édition de la fin du fichier XML $xml .= ''; $xml .= ''; // affichage flux dynamique print $xml; // enr de flux // écriture dans le fichier //$fp = fopen("flux.xml", 'w+'); //fputs($fp, $xml); //fclose($fp); mysql_close(); // clean str for xml parsers function clean_up($str){ $str = stripslashes($str); $str= str_replace(" "," ",$str) ; $str= str_replace("&"," et ",$str) ; $str = xmlEntities($str); // cleanup word special characters which are not covered by get_html_translation_table() $str = str_replace( array("\x82", "\x84", "\x85", "\x91", "\x92", "\x93", "\x94", "\x95", "\x96", "\x97"), array("‚", "„", "…", "‘", "’", "“", "”", "•", "–", "—"),$str); return $str; } // *************************************************************************************** // Another way of converting HTML entities into numeric entities to please XML parsers // is using two arrays as conversion tables in a preg_replace function. // The conversion table mechanism is based on Ryan's examples above. // *************************************************************************************** function xmlEntities($s){ //build first an assoc. array with the entities we want to match $table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); //now build another assoc. array with the entities we want to replace (numeric entities) foreach ($table1 as $k=>$v){ $table1[$k] = "/$v/"; $c = htmlentities($k,ENT_QUOTES,"UTF-8"); $table2[$c] = "&#".ord($k).";"; } //now perform a replacement using preg_replace //each matched value in array 1 will be replaced with the corresponding value in array 2 $s = preg_replace($table1,$table2,$s); return $s; } ?>