
- #Javascript rss feed reader how to
- #Javascript rss feed reader code
- #Javascript rss feed reader download
Here, I’ll make a bunch of elements as a template and then plop them onto a webpage: fetch(RSS_URL)Ĭonst items = data.querySelectorAll("item") ĭocument.body. So, we can querySelectorAll for those elements and loop over them to do what we please. Initialize the RSS reader and specify the path to the Atom, RSS, or Media RSS feed. Include both jQuery JavaScript library and the rssreader.js at the bottom of the webpage. RSS is sorta like HTML in that it is nested elements. Create an empty container for your RSS reader. then(str => new window.DOMParser().parseFromString(str, "text/xml")) Then use the data like we would if we had a normal DOM reference.It definitely works in the browser, and it looks like Node has a very popular implementation. Let’s use JavaScript’s native fetch API since that’s the most widely applicable. Then we’ll need to make a network request to the URL the RSS feed lives at. That way you know at least you’re working with a valid response (parsing may fail on invalid responses). While a lot of APIs offer JSON responses, it’s less typical for RSS, although it does exist.įirst, it’s probably smart to validate the feed.

RSS is XML, and XML is arguably not as easy to work with than JSON. It also uses JQuery and the RSS2Json API. The goal is to request that RSS feed, parse it, and do something useful with the data in it. A basic web based RSS feed reader written using HTML, CSS and Javascript. **The video solution for this project will not work because it uses Google's deprecated AJAX Feed Reader API.Say you have an RSS feed like this one. Need to see the video solution for this project**? Visit the hosted github page to see this JavaScript Feed Reader Project in action.
#Javascript rss feed reader code
Implement the JavaScript code in your own app.js file.Delete the contents of the app.js file.
#Javascript rss feed reader download
Download the source code from the github repository above.This project took me about four hours to complete on my own given the extension research involved. The first to get the element you want and the second to traverse down to the value you want. So, what I learned was to traverse information within a select list, you have to do somewhat of a “double” traversal. Var e = document.getElementById("ddlViewBy") var strUser = e.options.text Which would make strUser be test2. If what you actually want is test2, then do this: Var e = document.getElementById("ddlViewBy") var strUser = e.options.value Would make strUser be 2. If you have a select element that looks like this: The solution came from StackOverflow user Paolo Berganino.
#Javascript rss feed reader how to
I learned how to get a selected value in a dropdown list using JavaScript. The biggest thing I learned is not actually shown in my project code.īut, I learned it in my quest to manipulate the data coming from the JavaScript feed object.

So, I searched until I found Feednami's Feed Reader API solution.Īfterwards, it was just a matter of putting my RSS's url into the script and then manipulating the data from the object to have it show onto the web page. Lets build an RSS feed reader Most news websites, blogs. In the past, you could use the Google AJAX Feed Reader API to fetch this information, but it has been discontinued. If you choose to implement the parser yourself, youll also practice how to parse XML. However, the problem with this project is I had to find a way to covert XML data that came from an RSS feed into a JavaScript Object. Normally, when you fetch content from a web page you can use JSON, which turns the content into an object.

Not because the project itself was difficult, but because the project specifications required using some sort of feed reader to fetch content from a RSS feed. This JavaScript feed reader project's objective is to grab an RSS feed from BBC News or another feed and then display it on your web page. JavaScript Feed Reader Project (Hosted on Github Pages) Source Files Share JavaScript Feed Reader Project Hosted Project
