1 (edited by Ludo 2005-09-17 22:54)

Topic: iso 88-59-1 problem

Hi,

I just noticed I got a small problem on my following pages:

http://www.pluriservices.net/actuinfo.php

http://www.pluriservices.net/actupresencepc.php

http://www.pluriservices.net/actup2p.php

’   é   à and others are not well screened.

Precision, theses pages use rss feed thanks to this code:

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = ""; 
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}

function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
//printf("<dt><b><a href='%s' target='_blank'>%s</a></b></dt>",
//trim($link),htmlspecialchars(trim($title)));
//printf("<dd>%s</dd>",htmlspecialchars(trim($description)));
printf("<b><a href='%s' target='_blank'>%s</a></b></br>",
trim($link),htmlspecialchars(trim($title)));
printf("%s</br></br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}

function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
//L'ADRESSE DU FIL RSS EST A INSERER CI-DESSOUS
$fp = fopen("http://www.thefeedyouwant.com/rss.xml","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d", 
xml_error_string(xml_get_error_code($xml_parser)), 
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>

Do you know how this problem could be solved?

Ludo,

Re: iso 88-59-1 problem

The problem is that you're running htmlspecialchars() on the content before outputting it. This is generally a good idea, but in this case, it appears as if the content contains markup that you probably don't want altered.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: iso 88-59-1 problem

and what should I do to avoid this problem?

Ludo,

Re: iso 88-59-1 problem

Well, from where are you fetching the RSS?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5 (edited by Ludo 2005-09-18 18:15)

Re: iso 88-59-1 problem

I'm fetching from different rss feeds which cause problems :

http://www.presence-pc.com/rss.xml

http://www.ratiatum.com/rss/news.rss

http://www.pcinpact.com/include/news.xml

But one feed ( http://permanent.nouvelobs.com/rss_permanent.xml ) I'm using has no problem with my parser.

Ludo,

Re: iso 88-59-1 problem

Ludo wrote:

I'm fetching from different rss feeds which cause problems :

http://www.presence-pc.com/rss.xml

http://www.ratiatum.com/rss/news.rss

http://www.pcinpact.com/include/news.xml

But one feed ( http://permanent.nouvelobs.com/rss_permanent.xml ) I'm using has no problem with my parser.

Ludo,

Some of those feeds are already correctly formatted, so I guess that could be part of your problem...

Re: iso 88-59-1 problem

Try replacing the line

printf("%s</br></br>",htmlspecialchars(trim($description)));

with

printf("%s</br></br>",trim($description));

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8

Re: iso 88-59-1 problem

works good now.

You're cool Ricard!

Ludo,