SimplePortal

Support => English Support => Topic started by: Where's Waldo? on June 23, 2011, 10:14:05 AM

Title: RSS Feed block error
Post 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.
Title: Re: RSS Feed block error
Post by: Kryzen on June 23, 2011, 03:12:05 PM
Hi :) Can you please post line 20, 21, 22, 23, 24 and 25? :P

Tah Zonemaster
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 23, 2011, 03:31:53 PM
Sure, any idea what file the error is refering to?
Title: Re: RSS Feed block error
Post by: 130860 on June 23, 2011, 10:04:10 PM
your feed url is probably causing the error:

http://feed2.w3.org/check.cgi?url=http%3A//feeds.feedburner.com/Yamaha-BikeBlog
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 23, 2011, 10:35:21 PM
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.
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 24, 2011, 08:43:19 AM
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.
Title: Re: RSS Feed block error
Post by: [SiNaN] on June 24, 2011, 08:47:39 AM
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
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 24, 2011, 08:51:44 AM
Thanks for the suggestion, no that did not work, it brought up the same error
Title: Re: RSS Feed block error
Post by: [SiNaN] on June 24, 2011, 12:39:02 PM
Let's try this then.

Sources/PortalBlocks.php

Code: (Find) [Select]
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);
}

Code: (Replace) [Select]
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);
}
}

Code: (Find) [Select]
$items[] = array(
'title' => $item['TITLE'],

Code: (Replace) [Select]
fix_encoding($item['TITLE']);
fix_encoding($item['DESCRIPTION']);

$items[] = array(
'title' => $item['TITLE'],
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 24, 2011, 01:08:40 PM
Execelent, that did the trick and it's working fine now   :applause:
Thank you very much ;D
Title: Re: RSS Feed block error
Post by: [SiNaN] on June 24, 2011, 01:14:33 PM
Glad that it worked. I really need to re-code the RSS feed block for the next version.
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 24, 2011, 01:17:24 PM
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.
Title: Re: RSS Feed block error
Post by: [SiNaN] on June 24, 2011, 01:20:21 PM
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.
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 24, 2011, 01:24:30 PM
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.
Title: Re: RSS Feed block error
Post by: [SiNaN] on June 24, 2011, 01:26:28 PM
You can check the character encoding used by viewing the page source. There should be something like this in the header:

Code: [Select]
var smf_charset = "UTF-8";
smf_charset variable there will be set as the forum charset.
Title: Re: RSS Feed block error
Post by: Where's Waldo? on June 24, 2011, 03:09:31 PM
Ah, ok, I found this
Code: [Select]
var smf_charset = "ISO-8859-1";
SimplePortal 2.3.8 © 2008-2024, SimplePortal