Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>RSS Reader</title>
- </head>
- <body style="width: 500px;" onload="loadDoc()">
- <h3 style="text-align: center;">
- RSS Reader
- </h3>
- <br />
- <article >
- <div id="demo" style="margin: 0 auto; padding-top: 10px;">
- </div>
- </article>
- </body>
- <script>
- function loadDoc() {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- myFunction(this);
- }
- };
- xhttp.open("GET", "rss.xml", true);
- xhttp.send();
- }
- function myFunction(xml) {
- var i;
- var xmlDoc = xml.responseXML;
- var table="<div>RSS Title</div>";
- var x = xmlDoc.getElementsByTagName("channel");
- for (i = 0; i <x.length; i++) {
- table += "<div>Titlu:" +
- x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue +
- "</div><div>Link:<a href='"+x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue+"'>" +
- x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue +
- "</a></div><div>Descriere:"+
- x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue +
- "</div></br>";
- }
- var x = xmlDoc.getElementsByTagName("item");
- for (i = 0; i <x.length; i++) {
- table += "<div>Titlu:" +
- x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue +
- "</div><div>Link:<a href='"+x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue+"'>" +
- x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue +
- "</a></div><div>Descriere:"+
- x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue +
- "</div></br>";
- }
- document.getElementById("demo").innerHTML = table;
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement