Bonjour,
J'essaie d'ajouter un flux RSS sur mon site, mais je n'arrive pas à le valider.
Je vous donne le code, le code généré, et la liste des erreurs, si vous voulez bien y jeter un oeil ce serait sympa, merci d'avance.
Code PHP :
Il y a un autre truc bizarre, quand j'ajoute cette ligne dans les <item>, ça n'affiche plus rien sur la page :
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 <?php header('Content-Type: text/html"; charset=iso-8859-1'); require_once('./script/connex.php'); echo' <rss version="2.0"> '; //si c'est la liste des dernières définitions qui est demandée if(isset($_GET['article']) AND $_GET['article']==0) { echo '<channel>'; echo '<title>Derniers articles</title>'; echo'<link>http://www.monsite.com</link>'; echo '<description><![CDATA[Nouveaux Articles]]></description>'; $req="SELECT id,titre,contenu FROM articles ORDER BY id DESC LIMIT 0,10 "; $res=mysql_query("$req"); while($R=mysql_fetch_array($res)) { $art=stripslashes($R['contenu']); // Le nombre le lettres avant les ... $maxL =150; if (strlen($art) >= $maxL) {$art= substr($art,0,$maxL) . "..." ; }; $art= strip_tags($art); $titre=stripslashes($R['titre']); $id=$R['id']; echo ' <item> <link>http://www.monsite.com/'.$R['id'].'.htm</link> <title>'.$titre.'</title> <description>'.$art.'</description> </item>'; ;}//ferme whille // édition de la fin du fichier XML echo'</channel>'; ;} echo '</rss>'; ?>
Code : Sélectionner tout - Visualiser dans une fenêtre à part <guid isPermaLink="true">http://www.monsite.com/'.$R['id'].'.htm</guid>
Ca c'est la liste d'erreur que me renvoie le validateur RSS du W3C :
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 This feed does not validate. * line 53, column 50: Undefined named entity: eacute (4 occurrences) [help] <description>Partie d'une population . Un échantillon ... ^ In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations. * Feeds should not be served with the "text/html"" media type [help] * line 12, column 1: item should contain a guid element (10 occurrences) [help] </item> ^ * line 90, column 8: Missing atom:link with rel="self" [help] </item></channel></rss>
Ca c'est le code source de la page générée :
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 <rss version="2.0"> <channel> <title>Derniers articles</title> <link>http://www.monsite.com</link> <description><![CDATA[Nouveaux articles proposés sur mon site]]></description> <item> <link>http://www.monsite.com/article1.htm</link> <guid isPermaLink="true">http://www.monsite.com/article1.htm</guid> <title>titre de l'article </title> <description><![CDATA[150 caractères du premier article...]]</description> </item> <item> <link>http://www.monsite.com/article2.htm</link> <guid isPermaLink="true">http://www.monsite.com/article2.htm</guid> <title>titre de l'article</title> <description><![CDATA[150 premiers caractères de l'article...]]</description> </item> </channel> </rss>
Partager