rbren / rss-parser

A lightweight RSS parser, for Node and the browser
MIT License
1.39k stars 209 forks source link

reddit-atom and reddit-home not parsed #155

Open Arogova opened 4 years ago

Arogova commented 4 years ago

Hi, Parsing fails for the test files "reddit-atom.rss" and "reddit-home.rss" in a browser (Chrome v80) with error :

Uncaught TypeError: Cannot read property 'create' of undefined at Builder.buildObject (builder.js:116) at Object../lib/utils.js.utils.getContent (utils.js:26) at parser.js:209 at Array.forEach () at Parser.buildRSS (parser.js:202) at Parser.buildRSS2 (parser.js:177) at parser.js:41 at Parser. (parser.js:303) at Parser.emit (events.js:146) at SAXParser.onclosetag (parser.js:261)

It seems to be caused by require('xmlbuilder') (builder.js line 7) returning undefined.

Is this an error on my part ?

Thanks, Alexandra

rbren commented 4 years ago

Thanks for reaching out!

How are you adding rss-parser to the browser? Are you just including dist/rss-parser.min.js, or are you using require('rss-parser')?

Arogova commented 4 years ago

Just adding dist/rss-parser.min.js and calling it like so :

let parser = new RSSParser({defaultRSS: 2.0}); parser.parseString(fileText, function(err, result){ if (err) throw err; // Doing stuff to the result });

The fileText is the result of FileReader.readAsText