Flux RSS

Fermé
neokrome - 21 mai 2013 à 15:11
loupix57 Messages postés 316 Date d'inscription mercredi 20 mars 2013 Statut Membre Dernière intervention 1 juin 2015 - 27 mai 2013 à 14:32
Bonjour, je suis un peu bloquer...
$xml_file = new DOMDocument("1.0");

function &init_news_rss(&$xml_file)
{
        $root = $xml_file->createElement("rss"); // création de l'élément
        $root->setAttribute("version", "2.0"); // on lui ajoute un attribut
        $root = $xml_file->appendChild($root); // on l'insère dans le noeud parent (ici root qui est "rss")
        
        $channel = $xml_file->createElement("channel");
        $channel = $root->appendChild($channel);
                
        $desc = $xml_file->createElement("description");
        $desc = $channel->appendChild($desc);
        $text_desc = $xml_file->createTextNode("Partage de connaissances en tous genres"); // on insère du texte entre les balises <description></description>
        $text_desc = $desc->appendChild($text_desc);
        
        $link = $xml_file->createElement("link");
        $link = $channel->appendChild($link);
        $text_link = $xml_file->createTextNode("http://www.bougiemind.info");
        $text_link = $link->appendChild($text_link);
        
        $title = $xml_file->createElement("title");
        $title = $channel->appendChild($title);
        $text_title = $xml_file->createTextNode("Bougie'S mind");
        $text_title = $title->appendChild($text_title);
        
        return $channel;
}
		
		
$xml_file->save("news_FR_flux.xml");


En gros voila, j'ai ce petit fichier php qui me crée un fichier XML, mais à l'intérieur, je ne retrouve que l'infos de version... de quoi cela peut-il venir?
A voir également:

1 réponse

loupix57 Messages postés 316 Date d'inscription mercredi 20 mars 2013 Statut Membre Dernière intervention 1 juin 2015 14
27 mai 2013 à 14:32
Et en mettant $channel = $root->appendChild($channel); à la fin du script ?
0