You can also use this generic rss parsing script.


# Script rss.txt
var str source, list
var str rss ; cat $source > $rss
set $wsep="," ; var int count ; set $count = { wen $list }
while ( { sen -c -r "^<item\>&</item\>^" $rss } > 0 )
do
    var str item ; stex -c -r "^<item\>&</item\>^" $rss > $item
    var int index ; set $index = 1 ; var str line ; set $line=""
    var str list2 ; set $list2 = $list
    while ($index <= $count)
    do
        var str tag ; wex -p (makestr(int($index))) $list2 > $tag
        var str val ; stex -r -c ("^<"+$tag+">&</"+$tag+"\>^") $rss >
$val
        stex -r -c ("^<"+$tag+"\>^]") $val > null
        stex -r -c ("[^</"+$tag+"\>^") $val > null
        set $line = $line + $val + "\t"
        set $index = $index + 1
    done
    while ( { sen -r "^\n^" $line } > 0 )
        sal -r "^\n^" " " $line > null
    while ( { sen -r "^<&\>^" $line } > 0 )
         sal -r "^<&\>^" "" $line > null
    echo $line
done



Save the script as some file C:/rss.txt. Execute it as

script "C:/rss.txt" source"http://feeds.reuters.com/reuters/
businessNews") list("title,link")

or

script "C:/rss.txt" source("http://feeds.reuters.com/reuters/
businessNews") list("title,link,description")

etc.

source() is the source rss feed URL.
list() is a list of values to extract and display. Separate values by
comma.

The first command is showing me the following output as of this
moment. (I have cut off end parts ...)



Reuters: Business
News                                                  http://www.reuters.com
Reuters
News
http://www.reuters.com
Exxon quarterly profit down 68 percent, misses Street
http://feeds.reuters.com/~r/reuters/businessNews/...
P&amp;G, Colgate quarterly results top expectations
http://feeds.reuters.com/~r/reuters/businessNews/~3/...
Oil companies give cool outlook as profits tumble
http://feeds.reuters.com/~r/reuters/businessNews/~3/...
VW sees tough year-end; Mazda ups FY target
http://feeds.reuters.com/~r/reuters/businessNews/~3/...
Nintendo cuts forecast as Wii loses sparkle
http://feeds.reuters.com/~r/reuters/businessNews/~3/...
Sprint loss widens, but fewer subscribers flee
http://feeds.reuters.com/~r/reuters/businessNews/~3/...
Motorola sees better-than-expected Q4 profit
http://feeds.reuters.com/~r/...



Script is in biterscripting ( http://www.biterscripting.com ).



Richard

On Oct 6, 5:08 pm, NRutman <nathan.rut...@gmail.com> wrote:
> Hello,
>
> I'm trying to parse RSS feeds with JQuery in order to extract data.
> Here's what I've tried:
>
>   $.get('php-lib/proxy.php', {url: 'http://feeds.reuters.com/reuters/
> businessNews'}, function(data, textStatus) {
>     var feed = $(data);
>     var list = $('#headlinesFeed');
>     var html = [];
>     feed.find('item').each(function() {
>       var item = $(this);
>       var title = item.find('title').text();
>       var link = item.find('link').text();
>       var desc = item.find('description').html();
>       html.push('<li><a href="' + link + '" target="_blank">' + title
> + '</a></li>');
>     });
>     list.html(html.join(''));
>   });
>
> This seems to work ok, except the link attribute is empty.  It
> consistently mis-parses the link attribute.  I've tried various 
> feeds:http://finance.yahoo.com/rss/topstorieshttp://feeds.reuters.com/reuters/mergersNewshttp://feeds.reuters.com/reuters/businessNews
>
> All of them parse the link tag as empty.  Even stranger, if I specify
> the datatype as "xml" via the last parameter in the $.get() function,
> I get no data.
>
> Anybody have some working real-world knowledge to share with me about
> parsing RSS with JQuery??
>
> Thanks,
> -Nate

Reply via email to