Friday, April 19, 2013

Tiny Tiny RSS Reader : This XML Document is Invalid

I just came across this problem for this feed : http://techcircle.vccircle.com/feed/

The problem being the whitespaces at the beginning of the xml.
So we have to trim the response.

Here is the solution : 

1. Open the file lib/simplepie/simplepie.inc
2. Somewhere around the line #1342 - You will find : 

// Loop through each possible encoding, till we return something, or run out of possibilities
foreach ($encodings as $encoding)
{
// Change the encoding to UTF-8 (as we always use UTF-8 internally)
if ($utf8_data = $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8')))


Add the following line as the first statement in the foreach loop : 
$this->raw_data = trim($this->raw_data);

Now the code should look like : 

// Loop through each possible encoding, till we return something, or run out of possibilities
foreach ($encodings as $encoding)
{
$this->raw_data = trim($this->raw_data);
// Change the encoding to UTF-8 (as we always use UTF-8 internally)
if ($utf8_data = $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8')))

No comments:

Blog Archive