SimplePortal
Support => English Support => Topic started by: Where's Waldo? on June 23, 2011, 10:14:05 AM
-
I'm trying to install a RSS Feed block and get this error on preview and when adding the block
"XML error: Invalid character at line 23 "
SMF 2.0 final, Simple Portal 2.33
Feed I'm trying to add http://feeds.feedburner.com/Yamaha-BikeBlog
Any help is appreciated.
-
Hi :) Can you please post line 20, 21, 22, 23, 24 and 25? :P
Tah Zonemaster
-
Sure, any idea what file the error is refering to?
-
your feed url is probably causing the error:
http://feed2.w3.org/check.cgi?url=http%3A//feeds.feedburner.com/Yamaha-BikeBlog
-
Thanks for that, I have it working on other sites so I was confussed when I tried setting it up on another forum and it didn't work.
Weird.
-
Hi :) Can you please post line 20, 21, 22, 23, 24 and 25? :P
Tah Zonemaster
I checked those lines in the index.php file and there is no mention of XML so I'm lost as to which file to check.
-
Those lines are from the feed itself.
What's the exact URL you are adding? Is it this one?
http://feeds.feedburner.com/Yamaha-BikeBlog
If yes, see if this one works:
http://feeds.feedburner.com/Yamaha-BikeBlog?format=xml
-
Thanks for the suggestion, no that did not work, it brought up the same error
-
Let's try this then.
Sources/PortalBlocks.php
if (function_exists('mb_convert_encoding'))
{
preg_match('~encoding="([^"]*)"~', $xml_data, $xml_charset);
if (!empty($xml_charset[1]) && $xml_charset != $context['character_set'])
$xml_data = mb_convert_encoding($xml_data, $context['character_set'], $xml_charset[1]);
}
elseif (function_exists('iconv'))
{
preg_match('~encoding="([^"]*)"~', $xml_data, $xml_charset);
if (!empty($xml_charset[1]) && $xml_charset != $context['character_set'])
$xml_data = iconv($xml_charset[1], $context['character_set'], $xml_data);
}
global $xml_charset;
preg_match('~encoding="([^"]*)"~', $xml_data, $xml_charset);
if (!function_exists('fix_encoding'))
{
function fix_encoding(&$string)
{
global $context, $xml_charset;
static $fix_encoding;
if (!isset($fix_encoding))
$fix_encoding = !empty($xml_charset[1]) && $xml_charset != $context['character_set'] && (function_exists('mb_convert_encoding') || function_exists('iconv'));
elseif (!$fix_encoding)
return;
if (function_exists('mb_convert_encoding'))
$string = mb_convert_encoding($string, $context['character_set'], $xml_charset[1]);
else
$string = iconv($xml_charset[1], $context['character_set'], $string);
}
}
$items[] = array(
'title' => $item['TITLE'],
fix_encoding($item['TITLE']);
fix_encoding($item['DESCRIPTION']);
$items[] = array(
'title' => $item['TITLE'],
-
Execelent, that did the trick and it's working fine now :applause:
Thank you very much ;D
-
Glad that it worked. I really need to re-code the RSS feed block for the next version.
-
Again thanks :thumbsup:
Any idea why the original code worked fine in other instance yet on this site it didn't? All mods and themes are identical with each.
-
Almost all feeds will work fine on forums running with UTF-8 charset. It's difficult to handle feeds in forums with other charsets though. This forum you were working with wasn't UTF-8, I assume.
-
I'm not sure about the UTF-8 thing for that site. I only have english langauge on it and just set it up as standard.
-
You can check the character encoding used by viewing the page source. There should be something like this in the header:
var smf_charset = "UTF-8";
smf_charset variable there will be set as the forum charset.
-
Ah, ok, I found this
var smf_charset = "ISO-8859-1";