forked from danmactough/node-feedparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.js
More file actions
27 lines (25 loc) · 664 Bytes
/
simple.js
File metadata and controls
27 lines (25 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*!
* node-feedparser
* Copyright(c) 2013 Dan MacTough <danmactough@gmail.com>
* MIT Licensed
*/
var FeedParser = require(__dirname+'/..')
, fs = require('fs')
, feed = __dirname+'/../test/feeds/rss2sample.xml';
fs.createReadStream(feed)
.on('error', function (error) {
console.error(error);
})
.pipe(new FeedParser())
.on('error', function (error) {
console.error(error);
})
.on('meta', function (meta) {
console.log('===== %s =====', meta.title);
})
.on('readable', function() {
var stream = this, item;
while (item = stream.read()) {
console.log('Got article: %s', item.title || item.description);
}
});