Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 4:56 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Reading Rss feeds
PostPosted: August 30th, 2006, 12:34 pm 
Offline

Joined: January 19th, 2005, 5:15 pm
Posts: 83
Location: Netherlands
Does anyone ever tried to read a rss feed into opus.

I tried to find some sources on extracting XML, reading RSS and using activeXobjects like javascript does. But didn't found any really good resources till now.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: August 30th, 2006, 3:39 pm 
Offline

Joined: January 19th, 2005, 5:15 pm
Posts: 83
Location: Netherlands
I started some development where i manually get all information from the xml file.

Here is the code.
Code:
readRss("http://www.nu.nl/deeplink_rss2/index.jsp?r=Algemeen")

function readRss( $rssUrl )
{
   // get rss / xml file from internet
   var newData = InternetGetData( $rssUrl )
   if( !newData )   return false;
      
   // define array
   var rssArr = new Array();
   rssArr['item'] = new Array();
   
   // set main data from rss feed in array, like title / data / description
   rssArr['title']      = stripFromTags( newData, '<title>', '</title>');
   // There is more, but not needed right now
   
   // fill array
   var dataArr = newData.split('<item>');
   for( i=1; i < dataArr.length; i++)
   {
      rssArr['item'][i] = new Array();
      rssArr['item'][i]['title']         = stripFromTags( dataArr[i], '<title>', '</title>')
      rssArr['item'][i]['link']         = stripFromTags( dataArr[i], '<link>', '</link>')
      rssArr['item'][i]['description']   = stripFromTags( dataArr[i], '<description>', '</description>')
      rssArr['item'][i]['pubDate']      = stripFromTags( dataArr[i], '<pubDate>', '</pubDate>')
      rssArr['item'][i]['category']      = stripFromTags( dataArr[i], '<category>', '</category>')

      // remove other tags 'n data  :
      rssArr['item'][i]['description'] = str_replace('<![CDATA[', '', rssArr['item'][i]['description'] )
      rssArr['item'][i]['description'] = str_replace(']]>', '', rssArr['item'][i]['description'] )
   }
   
   // return full rss array
   return rssArr;
}

// strip text from two tags : <title>text</title>
function stripFromTags(input, startTag, endTag)
{
   return input.split(startTag, 1)[1].split(endTag, 1)[0];
}
   
// string functions
function str_replace(findThis, replaceWith, str)
{
   return str.toString().split(findThis).join(replaceWith);
}


This seems to work, on a very basic level..
Anybody some comments ? They're welcome!


Top
 Profile  
 
 Post subject:
PostPosted: August 30th, 2006, 3:59 pm 
Offline

Joined: January 19th, 2005, 5:15 pm
Posts: 83
Location: Netherlands
Other little issue :
If i use count on an array, like the following example:

Code:
var array = new Array()

array['title'] = 'This is a title';
array['date'] = '29-08-2006';
array['description'] = 'This is an example description.';

trace.Debug( array.length )



The length wil return 0. If i use numbers as array keys, it will work, and display '3'.
Can i fix this ?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: August 30th, 2006, 5:59 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Perhaps you could use Magpie and then use either an Browser object to display your results.

Location for source code, links, etc.
http://magpierss.sourceforge.net/

This articule explains how to do it.
http://www.olate.co.uk/articles/view.php?id=214

If you get something like this working, would you be so kind as to share it with the rest of us? I think this could really be useful in many different situations/applications.

I would do this myself if I had time, but am using different tools right now and haven't been able to do much Opus stuff lately.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 30th, 2006, 6:30 pm 
Offline

Joined: October 26th, 2004, 10:23 am
Posts: 666
Location: Digital Workshop
Reemski wrote:
The length wil return 0. If i use numbers as array keys, it will work, and display '3'.
Can i fix this ?

Erm - no! Array indexes must be integers - it is not a map (in programming parlance).

_________________
ddww Opus Developer


Top
 Profile Visit website  
 
 Post subject:
PostPosted: August 31st, 2006, 10:09 am 
Offline

Joined: January 19th, 2005, 5:15 pm
Posts: 83
Location: Netherlands
bwpatric wrote:
Perhaps you could use Magpie and then use either an Browser object to display your results.

If you get something like this working, would you be so kind as to share it with the rest of us? I think this could really be useful in many different situations/applications.


I have thought about using php to read the rss feed from inet. We don't need any open source scripts for that because we've done that many times inhouse.

But i can't show the results in a browser object, because the items need to be shown in a special box, on top of the (or in a special place) in the opus presentation. Here it wil show the title, and 2 lines of the item. These two lines must scroll, till the whole item is shown. Then the next item must be displayed.

I will post some results when i'm done.
I'm now working on a total Opus solution.

This script will download an rss feed (or multiple) once an hour, and save it in some vars. Then it will show the title, and some of the content, and scroll, as said before.


Top
 Profile  
 
 Post subject:
PostPosted: August 31st, 2006, 10:12 am 
Offline

Joined: January 19th, 2005, 5:15 pm
Posts: 83
Location: Netherlands
Duncan Lilly wrote:
Erm - no! Array indexes must be integers - it is not a map (in programming parlance).


Ah... I'm used to php programming, where an $array['key']='value' will fill in as [0]='value', ['key']='value'

I'm going to try to make a simular function..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group