 | | Offres d'emplois |  | Lead developer PHP On recherche un développeur-intégrateur adepte des bonnes pratiques du Web.
Mission :
- Participer à la conception technique des projets web
... | |
 | | Avez vous lu ? |  | | |
|
 Générer des flux RSS | |  |

<?php
// --- génération de flux XML
class RSSGEN {
var $charset = 'ISO-8859-1';
var $xml_version = "1.0";
var $escape_values = 1;
var $rss_format = 1;
var $main_bloc_name = 'channel';
// --- envoi du header xml
function send_header() {
header("Content-Type: text/xml; charset=" . $this->charset);
}
// --- décode les caractères html d'un texte
function htmldecode($encoded) {
return strtr($encoded,
array_flip (get_html_translation_table(HTML_ENTITIES)));
}
// --- demarrage du document
function start_xml_doc() {
$txt = '<?xml version="' . $this->xml_version
. '" encoding="' . $this->charset . '"?>' . chr(10);
if ($this->rss_format == 1) $txt .= '<rss version="2.0">'
. chr(10);
$txt .= '<' . $this->main_bloc_name . '>' . chr(10);
return($txt);
}
// --- fin du document
function end_xml_doc() {
$txt .= '</' . $this->main_bloc_name . '>' . chr(10);
if ($this->rss_format == 1) $txt .= '</rss>' . chr(10);
return($txt);
}
// --- affichage d'une ligne d'infos
function display_xml_element($key, $val) {
if ($this->escape_values) {
$val = $this->htmldecode($val);
$val = htmlspecialchars($val);
}
if ($key) $txt = '<' . $key . '>' . $val . '</'
. $key . '>' . chr(10);
return($txt);
}
// --- affichage d'un tableau
function display_array($tb, $key) {
$txt = '<' . $key . '>' . chr(10);
reset($tb);
while(list($key2, $val2) = each($tb)) {
$txt .= $this->display_xml_element($key2, $val2);
}
$txt .= '</' . $key . '>' . chr(10);
return($txt);
}
}
?>
|
|
|
 |
|