rss-parser is a lightweight JavaScript library designed to convert RSS (and Atom) XML feeds into easily consumable JavaScript objects. It supports both Node.js environments and modern web browsers (with bundlers or pre-built distributions). The current stable version is 3.13.0, indicating active maintenance and regular updates. Key differentiators include its flexibility with both callback and Promise-based APIs, robust TypeScript support allowing custom field definitions for type safety, and the ability to parse either directly from a URL or an XML string. It provides a standardized output format, mapping common feed elements and offering a `contentSnippet` for HTML-stripped content. A notable consideration for browser usage is the need for a CORS proxy due to browser security restrictions on cross-origin requests.
npm install rss-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing an RSS feed from a URL, including custom type definitions for additional feed and item fields, error handling, and considerations for CORS proxies in browser environments. It showcases `async/await` syntax for promise resolution.
Read file content using `fs.readFile` or `fs.promises.readFile` and pass the string to `parser.parseString(fileContent)`.
Change `Parser.parseURL(...)` to `const parser = new Parser(); parser.parseURL(...)`.
Move all configuration options (e.g., `customFields`, `maxRedirects`) into the `new Parser({...})` constructor object.Remove the `.feed` accessor from the parsed object; directly access properties like `feed.title` and `feed.items`.
Update all code referencing `feed.entries` to `feed.items`.
You must use a CORS proxy to fetch the RSS feed. Examples include `https://cors-anywhere.herokuapp.com/` or `https://api.allorigins.win/get?url=` which forward the request and return the content with appropriate CORS headers.
Initialize the parser first: `const parser = new Parser();` and then call `parser.parseURL(...)`.
Route your `parseURL` request through a CORS proxy service, e.g., `parser.parseURL('https://cors-anywhere.herokuapp.com/' + 'https://example.com/feed.xml', ...)`.Ensure that every custom field defined in your TypeScript types (e.g., `CustomFeed`, `CustomItem`) is also listed in the `feed` or `item` array within the `customFields` option of the `Parser` constructor.
No dependency data recorded yet.