Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- </head>
- <button id="all" onClick="show_all()">Show all</button>
- <p id="demo"></p>
- <script>
- function show_all(){
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- myFunction(this);
- }
- };
- xhttp.open("GET", "albumy_shop.xml", true);
- xhttp.send();
- function myFunction(xml) {
- var xmlDoc = xml.responseXML;
- var album = xmlDoc.getElementsByTagName("album");
- var albumLen = album.length;
- for(var i = 0; i < albumLen; i++){
- 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>";
- }
- }
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement