1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
$doc = new XMLWriter();
$doc->openUri('un/chemin/vers/ou/creer/le/fichier.xml');
$doc->setIndent(TRUE);
$doc->startDocument('1.0', 'UTF-8');
$doc->startElement ('rss');
$doc->writeAttribute('version', '2.0'); // RSS
$doc->startElement ('channel'); // CHANNEL
$doc->writeElement('title', 'UN TITRE');
... etc ...
while ($articles = $sStmt->fetch()) {
$doc->startElement('item'); // ITEM
// Section CDATA
$doc->startElement('description');
$desc = '<p>Un paragraphe</p>
<a href="http://wwwdomaine.com">Un lien</a>
<i>italic</i>';
$doc->writeCdata($desc);
$doc->endElement();
// FIN Section CDATA
$doc->endElement(); // Fin élément ITEM
}
... etc ...
$doc->endElement(); // Fin élément CHANNEL
$doc->endElement(); // Fin élément RSS
$doc->flush(); |
Partager