Advertisement
Paarzivall

Untitled

Jan 24th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.37 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.     </head>
  6.     <button id="all" onClick="show_all()">Show all</button>
  7.     <p id="demo"></p>
  8.  
  9.     <script>
  10.         function show_all(){
  11.             var xhttp = new XMLHttpRequest();
  12.             xhttp.onreadystatechange = function() {
  13.                 if (this.readyState == 4 && this.status == 200) {
  14.                    myFunction(this);
  15.                 }
  16.             };
  17.             xhttp.open("GET", "albumy_shop.xml", true);
  18.             xhttp.send();
  19.  
  20.             function myFunction(xml) {
  21.                 var xmlDoc = xml.responseXML;
  22.                 var album = xmlDoc.getElementsByTagName("album");
  23.                 var albumLen = album.length;
  24.                 for(var i = 0; i < albumLen; i++){
  25.                    document.getElementById("demo").innerHTML+="<div style='width:30%; margin-bottom:1%; border:1px solid black'>Autor: "+xmlDoc.getElementsByTagName("autor")[i].childNodes[0].nodeValue+"<br>Tytuł: "+xmlDoc.getElementsByTagName("tytul")[i].childNodes[0].nodeValue+"<br>Okładka: "+xmlDoc.getElementsByTagName("okladka")[i].childNodes[0].nodeValue+"<br>Cena: "+xmlDoc.getElementsByTagName("cena")[i].childNodes[0].nodeValue+"<br>Ilość utworów: "+xmlDoc.getElementsByTagName("ilosc_utworow")[i].childNodes[0].nodeValue+"<div>";
  26.                 }
  27.             }
  28.         }
  29.     </script>
  30.  
  31. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement