 | | Offres d'emplois |  | Développeur web Développeur Web - maîtrise de PHP/MySQL Flash/ActionScript
- des compétences en graphisme sont indispensables
- une connaissance des serveurs Lin... | |
 | | Avez vous lu ? |  | | |
|
 Des outils pour générer des fichiers XML | |  |

<?php
// --- génération de flux XML
class RSSGEN {
var $charset = 'ISO-8859-1';
var $xml_version = "1.0";
var $escape_values = 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)));
}
// --- démarrage du document
function start_xml_doc() {
$txt = '<?xml version="' . $this->xml_version . '"
encoding="' . $this->charset . '"?>' . 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);
}
}
?>
|
|
|
 |
|