jneyens


I'm familiar with consuming RSS feeds in BuddyScript. The current task is somewhat more complicated.

I want to call http://soapbox.msn.com/rss.aspx userId=469324002549308322 to retrieve a list of all videos for the specific user. Then I want to "sort" this list based on the vidAt:rating node (highest rating first). The sorting has to be done in BuddyScript since the SoapBox RSS API does not provide this. I have 2 problems:

1. Reading the "vidAt:rating" does not return any value. Regular nodes such as guid are displayed

2. What's the BuddyScript code to sort this feed based on the video rating Something to get me started

http://www.codeproject.com/gadgets/SoapBoxGadget/feeddetail.jpg shows the format of the RSS XML.

Thanks!

Jochen




Re: Read RSS feed from SOAPBOX

Jeroen Bransen - J-Thread


1. Instead of "vidAt:rating" you should use "rating", that should work. Namespaces are ignored in buddyscript.
2. I think you should write your own sorting algorithm in buddyscript. This shouldn't be to hard, why not implement bubble sort for example





Re: Read RSS feed from SOAPBOX

Gruia Pitigoi-Aron - MSFT

Hi,

1. Jeroen is correct

2. You may find it easier to use BuddyScript's "order by" construct. Here is code that should get you going:

Code Snippet

datasource GetRSSFeedDataForSOAPBox(FEED_URL) => Title, Description, Guid, Rating

http {timeout="20" expire="in 2 minutes"}

FEED_URL

simple xml

rss

channel {loop=content}

item {loop=content}

title

description

guid

rating

variable AVAILABLE_VIDEOS = {}

Sorted SOAP Box List

TITLE, DESCRIPTION,GUID, RATING = GetRSSFeedDataForSOAPBox("http://soapbox.msn.com/rss.aspx userId=469324002549308322")

VIDEO.TITLE = TITLE

VIDEO.RATING = RATING

insert last in AVAILABLE_VIDEOS VIDEO

for value VIDEO in AVAILABLE_VIDEOS order by RATING desc

- Item: VIDEO

I hope this helps!

Gruia






Re: Read RSS feed from SOAPBOX

jneyens

Gruia,

This works great! Thank you very much for your assistance!

I have one other question though: on http://www.codeproject.com/gadgets/SoapBoxGadget/feeddetail.jpg you see the node "description" and "vidAtBig Smileescription". So, if BuddyScript neglects the name-space info then we end up having 2 "description" nodes. I need the content of the second node since this contains the plain txt version of the description. How do I distinguish between them

Thanks,

Jochen





Re: Read RSS feed from SOAPBOX

Gruia Pitigoi-Aron - MSFT

Hi Jochen,

Here is a workaround. (Thanks to Gray for helping out!)

Code Snippet


datasource GetRSSFeedDataForSOAPBox(FEED_URL) => Title, Description, Guid, Rating

http {timeout="20" expire="in 2 minutes"}

FEED_URL

simple xml

rss

channel {loop=content}

item {loop=content}

title

description {loop = content}

guid

rating

variable AVAILABLE_VIDEOS = {}

Sorted SOAP Box List

TITLE, DESCRIPTION, GUID, RATING = GetRSSFeedDataForSOAPBox("http://soapbox.msn.com/rss.aspx userId=469324002549308322")

VIDEO.TITLE = TITLE

VIDEO.RATING = RATING

VIDEO.DESC = DESCRIPTION

//check if I have the easy to read description

//this assumes that the nice desciption does not contain "<div><a href="

if StringSearch(DESCRIPTION, "<div><a href=") eq -1

insert last in AVAILABLE_VIDEOS VIDEO

for value VIDEO in AVAILABLE_VIDEOS order by RATING desc

- Item: VIDEO

There are two things done differently:

1. To get both descriptions to show up, there is a {loop=content} on the description. This will return two sets of values for each soapbox video - one will have the <description> and the other will have the <vidAt : description>

2. I have added a if statement that checks for which record to add and makes sure that it is the human readable description. Of course, this is a bit of a hack, but I think for this case should work quite nicely (and it does work for my tests).

I hope this helps,

Gruia





Re: Read RSS feed from SOAPBOX

jneyens

Works great!

Thanks Gruia ...





Re: Read RSS feed from SOAPBOX

Riaanvs

Thanks Gruia

This post was very helpful. One more question though:

If I use this procedure again, despite the fact that my datasource is set to expire="now", the array still contains the old set of values.

How do I clear this array before running through it again / populating it with my datasource content

Thanks
Riaan






Re: Read RSS feed from SOAPBOX

Gruia Pitigoi-Aron - MSFT

Hi Riaan,

You could just keep an empty list around and assign your list the empty list before filling it up again.

Gruia





Re: Read RSS feed from SOAPBOX

Riaanvs

Gruia

I understand that but would you mind showing us how that is done

Thanks
Riaan






Re: Read RSS feed from SOAPBOX

Gruia Pitigoi-Aron - MSFT

Hi Riaan,

Given the code in the posts above, adding the line AVAILABLE_VIDEOS = {} as follows will do the trick:

Code Block

Sorted SOAP Box List

AVAILABLE_VIDEOS = {}

TITLE, DESCRIPTION, GUID, RATING = GetRSSFeedDataForSOAPBox("http://soapbox.msn.com/rss.aspx userId=469324002549308322")

VIDEO.TITLE = TITLE

VIDEO.RATING = RATING

VIDEO.DESC = DESCRIPTION

//check if I have the easy to read description

//this assumes that the nice desciption does not contain "<div><a href="

if StringSearch(DESCRIPTION, "<div><a href=") eq -1

insert last in AVAILABLE_VIDEOS VIDEO

for value VIDEO in AVAILABLE_VIDEOS order by RATING desc

- VIDEO

I hope this helps!

Gruia





Re: Read RSS feed from SOAPBOX

Riaanvs

Thanks!

I had that, just in the wrong place .. Smile

Cheers
Riaan






Re: Read RSS feed from SOAPBOX

Ramon Dures

Hi,
do you have C# samples
tks






Re: Read RSS feed from SOAPBOX

Gruia Pitigoi-Aron - MSFT

No, this is all BuddyScript.

Thank you,

Gruia