rss
Description
An RSS parser
Author
Requirements
Documentation
A basic RSS parser, supporting 0.92, 1.0 and 2.0 formats.
All errors signalled by the feed reader are composite conditions of the exn and rss kinds.
[procedure] (rss:read [PORT])Reads an RSS feed from the given PORT, or from the value of (current-input-port), if no port is specified. A rss:feed record is returned.
[record] rss:feed[procedure] (rss:feed? x)
[procedure] (rss:feed-version FEED)
[procedure] (rss:feed-channel FEED)
[procedure] (rss:feed-items FEED)
[procedure] (rss:feed-base-uri FEED)
A record that holds information for an RSS feed. The version field contains a string, the channel field and the items hold a single rss:item and a list of rss:items, respectively. The base-uri field contains a string pointing to the base uri (if the xml:base attribute is defined in rss tag).
[record] rss:item[procedure] (rss:item? X)
[procedure] (rss:item-title ITEM)
[procedure] (rss:item-link ITEM)
[procedure] (rss:item-description ITEM)
[procedure] (rss:item-enclosures ITEM)
[procedure] (rss:item-attributes ITEM)
A record containing data of a RSS item. The title, link and description fields are strings. The rss:item-enclosures procedure returns a list of enclosure records (see below). The attributes field holds an association list mapping symbols to strings and contain all sub-elements of a specific RSS item, including the title, link description and enclosure values. So:
(eq? (alist-ref 'title (rss:item-attributes ITEM)) (rss:item-title ITEM)) ==> #t
The item attribute is an SXML expression of the form
(image (title STRING) ...)
where ... hold additional subelements of the image attribute.
[procedure] (rss:item-attribute ITEM SYMBOL)Returns the attribute SYMBOL of the RSS feed item ITEM or #f if the item does not contain an attribute of this name.
[procedure] (rss:item=? ITEM ITEM)Returns #t if the items have identical GUID attributes or (if no GUIDs are available) if the items have the same contents.
[record] rss:enclosureHolds the url of an embedded file, the mime-type of that file and the length in bytes. It's accessors are defined as follows:
[procedure] (rss:enclosure? X)[procedure] (rss:enclosure-url ENCLOSURE)
[procedure] (rss:enclosure-type ENCLOSURE)
[procedure] (rss:enclosure-length ENCLOSURE)
All the returned values are strings.
Repository
This egg is hosted on the CHICKEN Subversion repository:
https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/rss
If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.
Changelog
- 1.7 ported to CHICKEN 5 by Mario Goulart
- 1.6 support for xml:base attribute in rss tag
- 1.5 support for handling multiple enclosures, changed rss:enclosure to rss:enclosures [thanks again to Christian Kellermann]
- 1.4 improvements by [Christian Kellermann]
- 1.3 ported to chicken 4
- 1.2 fixed broken .meta file [reported by Mario Goulart]
- 1.1 Small fix in rss:item=? by Daishi Kato
- 1.0 Initial release
License
Copyright (c) 2004-2011, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.