A simple app that fetches and displays the last 10 items in an RSS feed. Requires the new XML parser in Run BASIC 1.01.
- BASICwebmaster BASICwebmaster Oct 8, 2007

input "Feed to fetch"; url$
if (url$ <> "") then
  call feedMe url$
else
  print "no URL entered!"
end if
end
 
sub feedMe url$
  xml$ = httpget$(url$)
  if xml$ = "" then
    print "error fetching feed!"
    'exit sub 'exit sub isn't working for some reason!
    end
  end if
 
  div feedMe
    xmlparser #rss, xml$
 
    #channel = #rss #element(1)
    #title = #channel #element("title")
    #link = #channel #element("link")
    #desc = #channel #element("description")
 
    html "<h3 class='feedMe-title'><a href='" + #link value$() + "'>" + #title value$() + "</a></h3>"
    html "<span class='feedMe-desc'>" + #desc value$() + "</span>"
    html "<hr id='feedMe-hr' />"
 
    for x = 1 to #channel elementCount()
      if (itemCount = 10) then exit for
      #item = #channel #element(x)
      if (#item key$() = "item") then
        #title = #item #element("title")
        #desc = #item #element("description")
        html "<h4 class='feedMe-post-title'><a href='" + #link value$() + "'>" + #title value$() + "</a></h4>"
        html "<div id='feedMe-item-" + str$(itemCount) + "' class='feedMe-post-content'>" + #desc value$() + "</div>"
        itemCount = itemCount + 1
        if (itemCount < 10) then html "<hr class='feedMe-post-hr' />"
      end if
    next x
  end div
end sub