Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.88k stars 602 forks source link

Loading XML from RSS feed. #502

Open theasteve opened 5 years ago

theasteve commented 5 years ago

I'm trying to load XML from an RSS feed. I'm using rss-parser to turn the rss feed url into JSON. However, the JSON response I get back leaves out the namespaces.

I'n order to grab the namespaces I have to hardcode them in via the customFields options. I would like to use node-xml2js to parse the XML directly from a rss feed URL. Is there any way to go about doing that using node-xml2js?

I tried using url library as follow:

const url = require('url');
const xml2js = require('xml2js');
var parser = new xml2js.Parser();

const convertRssIntoJson = rssFeed => {
   return new Promise((res, rej) => {
      url.parse(rssFeed, (err, rss) => {
            parser.parseString(rss, function (err, result) {
            console.dir(result);
            console.log(result);
          });         
       });
   });
};

convertRssIntoJson('https://www.nycgovparks.org/web/events/controller/rss.php?qs=c18');

Is there any way to parse the XML from a RSS feed or load the XML from a URL?

chepe263 commented 4 years ago

is it a podcast? can you use menoncello/podcast-parser?