Part of the EllisLab Network
This thread is a discussion for the wiki article: RSSParser
   
 
RSSParser
Posted: 13 September 2008 09:39 AM   [ Ignore ]  
Summer Student
Total Posts:  3
Joined  05-12-2008

Promising!  A couple things, though:

Line 40 is a typo:
&get;_instance();

should instead be

&get;_instance();

Also, $cache_path is undefined. 

Best,
M

Profile
 
 
Posted: 13 September 2008 10:20 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRank
Total Posts:  2825
Joined  01-07-2008

I’ve fixed up the get_instance bug.
Always try to follow &s with a space or use the html entity.

I believe $cache_path should be $filename or $cache_dir, but I’ve never used the library so I’ll leave changing that to someone else.  It’s only a log message after all.

 Signature 
Profile
MSG
 
 
Posted: 13 September 2008 11:51 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  3
Joined  05-12-2008

Yeah, I’ve been using $filename, and the parser works.  I’ll probably end up modifying it to my purposes, so I can parse multiple feeds in the same page load.

Profile
 
 
Posted: 11 December 2008 04:46 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  1
Joined  05-29-2008

Change this :

//Assign the channel data
        
$this->channel_data['title'] = $xml->channel->title;
        
$this->channel_data['description'] = $xml->channel->description;
      
        
//Build the item array
        
foreach ($xml->channel->item as $item)
        
{
            $data
= array();
            
$data['title'] = $item->title;
            
$data['description'] = $item->description;
            
$data['pubDate'] = $item->pubDate;
            
$data['link'] = $item->link;
            
$this->data[] = $data;
        
}

Into this :

if($xml->channel){
          
          
//Assign the channel data
        
$this->channel_data['title'] = $xml->channel->title;
        
$this->channel_data['description'] = $xml->channel->description;
      
        
//Build the item array
        
foreach ($xml->channel->item as $item)
        
{
            $data
= array();
            
$data['title'] = $item->title;
            
$data['description'] = $item->description;
            
$data['pubDate'] = $item->pubDate;
            
$data['link'] = $item->link;
            
$this->data[] = $data;
        
}
      
      }else{
                    
          
//Assign the channel data
        
$this->channel_data['title'] = $xml->title;
        
$this->channel_data['description'] = $xml->subtitle;
          
        
//Build the item array
        
foreach ($xml->entry as $item)
        
{
            $data
= array();
            
$data['title'] = $item->title;
            
$data['description'] = $item->content;
            
$data['pubDate'] = $item->published;
            
$data['link'] = $item->link;
            
$this->data[] = $data;
        
}
          
      }

If you get an error because some blogs using different “kind” of RSS xml format (i don’t know what is it).

Maybe you can add this to the lib.

Profile
 
 
Posted: 13 December 2008 01:56 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  38
Joined  11-20-2007

Hi,
When i heat F5 to refresh the page I get a PHP Warning ERROR:

A PHP Error was encountered
Severity: Warning
Message: unserialize() [function.unserialize]: Node no longer exists
Filename: libraries/RSSParser.php
Line Number: 75

Why is happening this?

 Signature 

A.

Profile
 
 
Posted: 16 March 2009 02:07 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  229
Joined  06-04-2007

is working ?

 Signature 

http://www.asinox.net
CodeIgniter code and more.

Profile
 
 
Posted: 29 March 2009 04:23 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  9
Joined  03-16-2009
Asinox - 16 March 2009 02:07 PM

is working ?

No, I got the same error as the penguin above.

Profile
 
 
Posted: 29 March 2009 04:27 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  229
Joined  06-04-2007

ok, anyway im using another one

http://www.derekallard.com/blog/post/building-an-rss-feed-in-code-igniter/

 Signature 

http://www.asinox.net
CodeIgniter code and more.

Profile
 
 
Posted: 03 July 2009 03:00 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  1
Joined  05-09-2007

I’m also getting the serialize() warning, it is apparently that serialize() does not place nice with SimpleXML. Some comprehensive Googling led me to this PHP bug, which isn’t actually a bug, and this super helpful post on Make Me Pulse, which seems like a solution but it just made my head hurt.

My solution is a bit more pragmatic: don’t serialize the XML.

You can see my version here: http://codeigniter.com/wiki/RSSParser-PhilMod/

Profile
 
 
Posted: 18 August 2009 09:51 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  9
Joined  07-19-2008

Phil Nelson,


I am using your library, but i am with a problem.
the encode type utf-8, i tried:
strip_tags(utf8_encode(htmlspecialchars($item->title)));
strip_tags(htmlspecialchars($item->title));
nothing work.
thanks for help

Profile
 
 
Posted: 18 August 2009 09:55 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  9
Joined  07-19-2008

Resolved:
utf8_encode(htmlentities($item->title,ENT_COMPAT,‘utf-8’));

Profile
 
 
Posted: 20 August 2009 07:00 PM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  9
Joined  07-19-2008

Hi guys,

i hava a problem when use rssparser and parser class by CI:
A PHP Error was encountered

Severity: Warning

Message: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 2

Filename: libraries/Parser.php

Line Number: 162

in line 162 print |{0}(.+?){/0}|s that is passed to preg_match
Any Ideas?
tks

Profile
 
 
Posted: 12 January 2010 02:23 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  36
Joined  07-06-2009

The unserialize() bug is caused by the caching. Turn off caching (set life=>0 to fetching parameters) and plugin works OK.

 Signature 

Codito, ergo sum - I code, therefore I am

Profile
 
 
Posted: 28 January 2010 05:22 PM   [ Ignore ]   [ # 13 ]  
Summer Student
Total Posts:  12
Joined  02-05-2008

Just cast the SimpleXML objects to strings.

$data = array();
$data['title'] = (string) $item->title;
$data['description'] = (string) $item->description;
$data['pubDate'] = (string) $item->pubDate;
$data['link'] = (string) $item->link;
$this->data[] = $data;
Profile
 
 
   
 
 
‹‹ Quick n Simple Query Browser      Hello ››
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 119921 Total Logged-in Users: 27
Total Topics: 126070 Total Anonymous Users: 2
Total Replies: 663136 Total Guests: 361
Total Posts: 789206    
Members ( View Memberlist )