bonjour
j'ai fait un tuto pour un créer un flux rss dynamique mais lorsque je clique pour le voir il m' affiche que le contenu et vide
code rss.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
 
 
<?php
function openXML(){
 
	// Ouverture du fichier
	$file = new DOMDocument();
	$file->formatOutput = true; 
	$file->load("rss.xml"); 
 
	//On retourne le fichier
	return $file;
}
	function createXML(){
 
	// Création du fichier en mémoire 
	$file = new DOMDocument("1.0","utf-8");
 
	// Création du noeud racine
	$root = $file->createElement("rss"); //On crée l élément racine
	$root->setAttribute("version", "2.0"); //On lui ajoute l attribut version (2.0)
	$root = $file->appendChild($root); //On insère la racine dans le document
 
	// Création du noeud channel 
	$element_channel = $file->createElement("channel");//On crée un élément channel
	$element_channel->setAttribute("id", "actualite"); //On donne un attribut id à notre channel
	$element_channel->setIdAttribute("id", true);
	$element_channel = $root->appendChild($element_channel);//On ajoute cet élément à la racine
 
	// Création du noeud description 
	$element_description = $file->createElement("description");//On crée un élément description
	$element_description = $element_channel->appendChild($element_description);//On ajoute cet élément au channel
 
	// Création du texte pour le noeud description 
	$texte_description = $file->createTextNode("centre de ressources et d’innovation"); //On crée un texte
	$texte_description = $element_description->appendChild($texte_description); //On insère ce texte dans le noeud description
 
	// Création du noeud link et ajout du texte à l élément 
	$element_link = $file->createElement("link");
	$element_link = $element_channel->appendChild($element_link);
	$texte_link = $file->createTextNode("www.site.org");
	$texte_link = $element_link->appendChild($texte_link);
 
	// Création du noeud title et ajout du texte à l élément 
	$element_title = $file->createElement("title");
	$element_title = $element_channel->appendChild($element_title);
	$texte_title = $file->createTextNode("Actualite site");
	$texte_title = $element_title->appendChild($texte_title);
 
	//On retourne le fichier XML
	return $file;
}
 
	function addOneNews($file, $titre,$datenews, $resume){
 
	//On récupère le channel
	$element_channel = $file->getElementsByTagName("channel")->item(0); // Création du noeud item 
	$element_item = $file->createElement("item"); // Ajout du noeud 
	$element_item = $element_channel->appendChild($element_item); 
	$element_channel = $file->getElementById("actualite");
 
	// Création du noeud item
	$element_item = $file->createElement("item");
	$element_item = $element_channel->appendChild($element_item);
 
	// Création du noeud title et ajout du texte à l élément 
	$element_title = $file->createElement("title");
	$element_title = $element_item->appendChild($element_title);
	$texte_title = $file->createTextNode($titre);
	$texte_title = $element_title->appendChild($texte_title);
 
	// Création du noeud link et ajout du texte à l élément 
	$element_link = $file->createElement("link");
	$element_link = $element_item->appendChild($element_link);
	$texte_link = $file->createTextNode("www.site.org");
	$texte_link = $element_link->appendChild($texte_link);
 
	// Création du noeud pubDate et ajout du texte à l élément 
	$element_date = $file->createElement("pubDate");
	$element_date = $element_item->appendChild($element_date);
	$texte_date = $file->createTextNode($datenews);
	$texte_date = $element_date->appendChild($texte_date);
 
	// Création du noeud author et ajout du texte à l élément 
	$element_author = $file->createElement("resume");
	$element_author = $element_item->appendChild($element_author);
	$texte_author = $file->createTextNode($resume);
	$texte_author = $element_author->appendChild($texte_author);
}
 
	function saveXML($file){
 
		//Sauvegarde du fichier
		$file->save("rss.xml");
	}
 
?>
scriptpour la page index
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
	//Création du fichier XML
	require("rss.php");
		$file = createXML();
 
		$connect = mysql_connect('localhost','root','') or die ("erreur de connexion");
		mysql_select_db('site',$connect) or die ("erreur de connexion base");
		setlocale (LC_ALL, 'fr_FR'); 
		$result = mysql_query("SELECT *,type_th,DATE_FORMAT(datenews, '%d %m %Y') AS dateus from actualite,thématique where actualite.id_th=thématique.id_th ORDER BY datenews DESC");
 
		while($data_news = mysql_fetch_array($result)){
			addOneNews($file,$data_news['titre'],$data_news['dateus'],$data_news['resume']);
		}
 
		mysql_close();
 
		saveXML($file);
 
	?>
le contenu xml créer
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
31
32
33
34
35
36
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel id="actualite">
<description>centre </description>
<link>www.site.org</link><title>Actualite site</title><item/>
<item>
<title>conference d'accessibilite</title>
<link>www.site.org</link>
<pubDate>15 08 2009</pubDate>
<resume>bla bala bla bla bla bla bla bla bla bla bla</resume>
</item>
<item/>
<item>
<title>nouvelle collection </title>
<link>www.site.org</link>
<pubDate>31 07 2009</pubDate>
<resume>bla bala bla bla bla bla bla bla bla bla bla</resume></item>
<item/>
<item><title>les normes d'accessibilite</title><link>www.site.org</link>
<pubDate>30 07 2009</pubDate><resume>bla bala bla bla bla bla bla bla bla bla bla</resume>
</item>
<item/>
<item>
<title>news : les dernieres marque exclusif</title>
<link>www.site.org</link><pubDate>23 07 2009</pubDate>
<resume>hhhh hhhh hhhh hhhhh hhhhhh hhhhh hhhhh hhhhhhhhhhh hhhhh  </resume>
</item>
<item/><item>
<title>projet biv ajouter</title>
<link>www.site.org</link>
<pubDate>16 07 2009</pubDate>
<resume>bla bala bla bla bla bla bla bla bla bla bla</resume>
</item>
</channel>
</rss>
j'observe qu'il avait un <item/> avant <item> ????????