Skip to content

Instantly share code, notes, and snippets.

@lambdaman2
Created October 1, 2012 11:16
Show Gist options
  • Select an option

  • Save lambdaman2/3811030 to your computer and use it in GitHub Desktop.

Select an option

Save lambdaman2/3811030 to your computer and use it in GitHub Desktop.
Impromptu: parse rss
(load "xml_lib.scm")
(define feedurl "http://feeds.guardian.co.uk/theguardian/world/rss")
;;
;; loads the feed and extracts title and url
;;
;;
(define get-articles-online
(lambda ()
(let* ((out '())
(feed (xml:load-url feedurl))
(titles (objc:nsarray->list (xml:xpath (xml:get-root-node feed)
"channel/item/title/text()")))
(urls (objc:nsarray->list (xml:xpath (xml:get-root-node feed)
"channel/item/link/text()"))))
(for-each (lambda (x y)
(let ((xx (objc:nsstring->string x))
(yy (objc:nsstring->string y)))
(set! out (append out (list (list xx yy))))))
titles urls)
out)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment