Reading an RSS feed(XML)

1 reply [Last post]
iholtum
User offline. Last seen 26 weeks 4 days ago. Offline
Joined: 2 Jun 2010

Is there a good tutorial or example code anywhere on the best way to read in xml or an RSS feed? I'd like to read in the feed and use it to determine the path to images to download. Thanks in advance for the help!

Replies

d3mac123
User offline. Last seen 1 week 5 days ago. Offline
Joined: 12 Feb 2010

If all you need is to get info from a feed, maybe you could just download the feed in a table and search it after:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- load needed modules
local http = require("socket.http")
local ltn12 = require("ltn12")
 
-- a simplified http.get function
function http.get(u)
  local t = {}
  local respt = request{
    url = u,
    sink = ltn12.sink.table(t)
  }
  return table.concat(t), respt.headers, respt.code
end
 
http.get("http://www.yourfeed.com/feed.rss")

this info was extracted from the ltn12 documentation at: http://w3.impa.br/~diego/software/luasocket/ltn12.html. I didn't test it but it should work fine.
Alex

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.