unread
v1.1.1
Published
A package for parsing RSS and Atom feeds
Downloads
22
Readme
Unread
A package for parsing RSS 2.0, Atom 1.0. Works on both Node.js and the browser.
Features
- Small footprint
- Query attributes helper (see below)
- Cross-platform works on browser and Node.js
- TypeScript ready
Installation
npm add unreadUsage
import { parse } from 'unread';
const res = await fetch('https://overreacted.io/rss.xml');
const rss = await res.text();
const output = await parse(rss);
// We support common attributes
const { feed, items } = output;
console.log(feed.title());
console.log(feed.feedLink());
// And you can also query custom ones (as long as we support that namespace)
console.log(item[0].get(['author', 'dc:creator'])); // returns first match or undefined
console.log(item[0].getMany(['atom:link[ref=enclosure]'])); // Array of nodesSupported namespaces
We support the followings XML namespaces:
http://www.w3.org/2005/Atom(atom)http://purl.org/rss/1.0/modules/content/(content)http://purl.org/dc/elements/1.1/(dc)http://purl.org/dc/elements/1.0/(dc)http://www.itunes.com/dtds/podcast-1.0.dtd(itunes)http://search.yahoo.com/mrss/(media)http://www.w3.org/1999/xhtml(xhtml)http://www.w3.org/XML/1998/namespace(xml)
Mapping
Feed
| Helper | RSS | Atom | | ------------- | -------------------------------------------------------- | ----------------------------- | | id() | | /feed/id | | title() | /rss/channel/title/rss/channel/dc:title | /feed/title | | description() | /rss/channel/description/rss/channel/itunes:subtitle | /feed/subtitle | | links() | /rss/channel/link | /feed/link/@href | | feedURL() | /rss/channel/atom:link[@rel="self"]/@href | /feed/link[@rel="self"]/@href | | updated() | /rss/channel/lastBuildDate/rss/channel/dc:date | /feed/updated | | published() | /rss/channel/pubDate | | | language() | /rss/channel/language/rss/channel/dc:language | /feed/@xml:lang | | image() | /rss/channel/image/rss/channel/itunes:image | /feed/logo | | generator() | /rss/channel/generator | /feed/generator |
Item
| Helper | RSS | Atom | | ------------- | ----------------------------------------------------------------- | ---------------------------------- | | id() | /rss/channel/item/guid | /feed/entry/id | | title() | /rss/channel/item/title/rss/channel/item/dc:title | /feed/entry/title | | description() | /rss/channel/item/description/rss/channel/item/dc:description | /feed/entry/summary | | content() | /rss/channel/item/content:encoded | /feed/entry/content | | links() | /rss/channel/item/link | /feed/entry/@href | | updated() | /rss/channel/item/dc:date | /feed/entry/updated | | published() | /rss/channel/item/pubDate/rss/channel/item/dc:date | /feed/entry/published | | image() | /rss/channel/item/media:thumbnail | | | enclosures() | /rss/channel/item/enclosure | /feed/entry/link[@rel=”enclosure”] |
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
- Louis-Dominique Dubeau for their work on saxes. We use
saxesto parse XML strings. - Dan MacTough for their work on node-feedparser. Our work is heavily inspired by
feedparser. - mmcdole for their work on gofeed. We adopted
gofeedfields mapping.
License
MIT © Ahmed T. Ali

