Quantcast
Channel: How to parse an RSS feed using JavaScript? - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by Alireza Fattahi for How to parse an RSS feed using JavaScript?

$
0
0

If you want to use a plain javascript API, there is a good example at https://github.com/hongkiat/js-rss-reader/

The complete description at https://www.hongkiat.com/blog/rss-reader-in-javascript/

It uses fetch method as a global method that asynchronously fetches a resource. Below is a snap of code:

fetch(websiteUrl).then((res) => {  res.text().then((htmlTxt) => {    var domParser = new DOMParser()    let doc = domParser.parseFromString(htmlTxt, 'text/html')    var feedUrl = doc.querySelector('link[type="application/rss+xml"]').href  })}).catch(() => console.error('Error in fetching the website'))

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>