sfFeed2Plugin-1.2.4 incompatible avec <![CDATA[
Bonjour à tous,
J'ai un problème avec sfFeed2Plugin-1.2.4
J'utilise le plugin pour
1) récupérer un flux RSS partenaire
2) le transformer en Objets
3) pour pouvoir l'afficher dans ma page.
Dans sfRssFeed.class à la ligne 52 le XML est transformé en objet via la fonction simplexml_load_string()
Et là j'ai deux comportements différents suivant les flux.
Cas 1
On est bien sur du Rss 2 mais la fonction génère une serie de warning et ne retourne par d'objet.
http://feeds.feedburner.com/Contispl...tDeContisPlage
Le XML
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:ra="http://www.feedshow.com/xmlrss/remoteads/">
<channel>
<title>ContisPlage.com: L'actualité de Contis Plage</title>
<description>Toute l'actualité de Contis-Plage et sa région.</description>
<link>http://www.contisplage.com</link>
<language>fr</language>
<item>
<title>"Contis-Plage vu du ciel"</title>
<description><![CDATA[<a href="http://www.contisplage.com/"><img src="http://www.contisplage.com/rss/archives.jpg" alt="Archives" border="0" width="76" height="76" align="left" style="margin-right: 10px;" /></a><p><b>Festival</b></p><p>Evènement</p><p>Le survol de Contis-Plage, c'est désormais possible ...</p>
<a href="http://www.facebook.com/pages/Contis-Plage-sur-ContisPlagecom/57927408769">Avant-premières : Rejoignez-nous sur Facebook</a>]]>
</description>
<link>http://www.contisplage.com/</link>
<pubDate>Sun, 17 Jun 2009 23:58:00 CET</pubDate>
</item>
</channel>
</rss> |
Les Warnings
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Sequence ']]>' not allowed in content in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: r-ContisPlagecom/57927408769">Avant-premières : Rejoignez-nous sur Facebook</a> in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : internal error in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: r-ContisPlagecom/57927408769">Avant-premières : Rejoignez-nous sur Facebook</a> in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Extra content at the end of the document in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: r-ContisPlagecom/57927408769">Avant-premières : Rejoignez-nous sur Facebook</a> in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52
Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/microcos-dev/Dev-nux/maplage-dev/trunk/plugins/sfFeed2Plugin-1.2.4/lib/sfRssFeed.class.php on line 52 |
Cas 2
On est toujours sur du Rss 2 mais cette fois ça marche.
http://blog.maplage.fr/feed/
Le XML
Code:
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
|
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>Le Blog de maPlage</title>
<atom:link href="http://blog.maplage.fr/feed/" rel="self" type="application/rss+xml" />
<link>http://blog.maplage.fr</link>
<description>Le littoral un peu, beaucoup, à la folie!!</description>
<lastBuildDate>Tue, 17 Nov 2009 10:36:40 +0000</lastBuildDate>
<generator>http://wordpress.org/?v=2.8.4</generator>
<language>en</language>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<item>
<title>A la recherche de plagistes correspondants locaux</title>
<link>http://blog.maplage.fr/2009/11/17/a-la-recherche-de-plagistes-correspondants-locaux/</link>
<comments>http://blog.maplage.fr/2009/11/17/a-la-recherche-de-plagistes-correspondants-locaux/#comments</comments>
<pubDate>Tue, 17 Nov 2009 10:36:40 +0000</pubDate>
<dc:creator>florian</dc:creator>
<category><![CDATA[Actualités]]></category>
<category><![CDATA[Featured]]></category>
<category><![CDATA[maplage]]></category>
<guid isPermaLink="false">http://blog.maplage.fr/?p=300</guid>
<description><![CDATA[Bonjour les plagistes.
Cette fois cest décidé, on a besoin de vous et de vos talents de reporters sans frontières afin de nous fournir de linformation locale !
Je ne peux pas malheureusement pas encore vous dévoiler votre future communauté de plagistes puisquelle est encore dans les cartons, mais en attendant on va pouvoir commencer à [...]]]></description>
<content:encoded><![CDATA[<p>Bonjour les plagistes.</p>
<p>Cette fois cest décidé, on a besoin de vous et de vos talents de reporters sans frontières afin de nous fournir de linformation locale !</p>
<p>Je ne peux pas malheureusement pas encore vous dévoiler votre future communauté de plagistes puisquelle est encore dans les cartons, mais en attendant on va pouvoir commencer à se connaître sans attendre <img src='http://blog.maplage.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Nous sommes donc en plein tour de France des plages à la rechercher de blogs (ou autres formats) locaux, gérés par des personnes passionnées par leur petit bout de bord de mer et son activité au quotidien.</p>
<p>Etant donné quil existe quelques 723 communes du bord de mer et peut-être autant (voire plus) de blogs locaux, nhésitez pas à vous manifester si vous désirez devenir un plagiste certifié <img src='http://blog.maplage.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Pour ceux qui auraient lenvie mais qui ne dispose pas dun blog ou autre support, contactez nous également, nous nous ferons un plaisir de vous aider dans votre démarche.</p>
<p style="text-align: center;">Pour nous contacter : <a href="mailto:florian@maplage.fr">florian<img class="alignnone size-full wp-image-301" title="arobase" src="http://blog.maplage.fr/wp-content/uploads/2009/11/arobase.png" alt="arobase" width="20" height="20" />maplage.fr</a> ou par téléphone : 02 40 20 25 94</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-303" title="correspondant" src="http://blog.maplage.fr/wp-content/uploads/2009/11/correspondant.png" alt="correspondant" width="300" height="300" /></p>
]]></content:encoded>
<wfw:commentRss>http://blog.maplage.fr/2009/11/17/a-la-recherche-de-plagistes-correspondants-locaux/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
</channel>
</rss> |
Je me suis donc dit que la fonction ne digéré pas les '<![CDATA[ ]]>'
J'ai donc tester ça :
$feedXml = MP_SF::get_partial("test/xml");
$feedXml = str_replace(']]>', '', $feedXml);
$feedXml = str_replace('<![CDATA[', '', $feedXml);
$feedXml = str_replace('^', '', $feedXml);
aze::debug($xml,1);
$feedXml = simplexml_load_string($xml);
Mais dans ces conditions j'ai l'erreur inverse ! :calim2: