React Native compatible RSS parser
Parse RSS data into a simple object structure. Currently supports;
- RSS 2.0 specification
- Atom 1.0 specification
- Itunes elements for both RSS 2.0 and Atom 1.0 feeds
Installation
npm install react-native-rss-parser --save
Usage example
import * as rssParser from 'react-native-rss-parser';
return fetch('http://www.nasa.gov/rss/dyn/breaking_news.rss')
.then((response) => response.text())
.then((responseData) => rssParser.parse(responseData))
.then((rss) => {
console.log(rss.title);
console.log(rss.items.length);
});
Parsed model
{
type: undefined,
title: undefined,
links: [{
url: undefined,
rel: undefined
}],
description: undefined,
language: undefined,
copyright: undefined,
authors: [{
name: undefined
}],
lastUpdated: undefined,
lastPublished: undefined,
categories: [{
name: undefined
}],
image: {
url: undefined,
title: undefined,
description: undefined,
width: undefined,
height: undefined
},
itunes: {
author: [{
name: undefined
}],
block: undefined,
categories: [{
name: undefined,
subCategories:[{
name: undefined
}]
}],
image: undefined,
explicit: undefined,
complete: undefined,
newFeedUrl: undefined,
owner: {
name: undefined,
email: undefined,
},
subtitle: undefined,
summary: undefined,
},
items: [{
id: undefined,
title: undefined,
imageUrl: undefined,
links: [{
url: undefined,
rel: undefined
}],
description: undefined,
content: undefined,
categories: [{
name: undefined
}],
authors: [{
name: undefined
}],
published: undefined,
enclosures: [{
url: undefined,
length: undefined,
mimeType: undefined
}],
itunes: {
authors: [{
name: undefined,
}],
block: undefined,
duration: undefined,
explicit: undefined,
image: undefined,
isClosedCaptioned: undefined,
order: undefined,
subtitle: undefined,
summary: undefined,
}
}]
}
Model mappings
Top Level elements
Parsed Value | RSS v2.0 | Atom v1.0 |
---|
title | title | title |
links | link | link |
description | description | subtitle |
language | language | |
copyright | copyright | rights |
authors | managingEditor | author |
published | pubDate | published |
updated | lastBuildDate | updated |
categories | category | category |
image | image | logo |
items | item | entry |
Item / Entry Level elements
Parsed Value | RSS v2.0 | Atom v1.0 |
---|
id | guid | id |
title | title | title |
imageUrl | | icon |
links | link | link |
description | description | summary |
content | content:encoded | content |
categories | category / dc:subject | category |
authors | author / dc:creator | contributor |
published | pubDate / dc:date | published |
enclosures | enclosures | link |
CHANGELOG
1.5.1
- Bug Fix: _this.getElementTextContentArray is not a function issue #16 (thanks to julianbragachi)
1.5.0
- Updated xmldom to version 0.3.0
- Change tests to use Jest to ensure refactoring did not break anything (using snapshot tests)
- Updated entire codebase to use up-to-date JavaScript syntax (arrow functions, const & let instead of var)
- Bug Fix: Atom v1 should return published date when no updated date available (thanks to Serra19)
Development setup
Clone this project from GitHub
npm install
npm test
Bugs / feature requests
If you find any bugs or have a feature request, please create an issue in GitHub.
Contributing
- Fork it (https://github.com/jameslawler/react-native-rss-parser)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
License
Distributed under the MIT license. See LICENSE
for more information.