Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>RSS Reader</title>
  6. </head>
  7. <body style="width: 500px;" onload="loadDoc()">
  8. <h3 style="text-align: center;">
  9. RSS Reader
  10. </h3>
  11. <br />
  12. <article >
  13.  
  14.  
  15. <div id="demo" style="margin: 0 auto; padding-top: 10px;">
  16. </div>
  17.  
  18. </article>
  19. </body>
  20. <script>
  21. function loadDoc() {
  22. var xhttp = new XMLHttpRequest();
  23. xhttp.onreadystatechange = function() {
  24. if (this.readyState == 4 && this.status == 200) {
  25. myFunction(this);
  26. }
  27. };
  28. xhttp.open("GET", "rss.xml", true);
  29. xhttp.send();
  30. }
  31. function myFunction(xml) {
  32. var i;
  33. var xmlDoc = xml.responseXML;
  34. var table="<div>RSS Title</div>";
  35. var x = xmlDoc.getElementsByTagName("channel");
  36. for (i = 0; i <x.length; i++) {
  37. table += "<div>Titlu:" +
  38. x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue +
  39. "</div><div>Link:<a href='"+x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue+"'>" +
  40. x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue +
  41. "</a></div><div>Descriere:"+
  42. x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue +
  43. "</div></br>";
  44. }
  45. var x = xmlDoc.getElementsByTagName("item");
  46. for (i = 0; i <x.length; i++) {
  47. table += "<div>Titlu:" +
  48. x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue +
  49. "</div><div>Link:<a href='"+x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue+"'>" +
  50. x[i].getElementsByTagName("link")[0].childNodes[0].nodeValue +
  51. "</a></div><div>Descriere:"+
  52. x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue +
  53. "</div></br>";
  54. }
  55. document.getElementById("demo").innerHTML = table;
  56. }
  57. </script>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement