SHARE
TWEET

Untitled

a guest Oct 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p><button onclick="loadXMLDoc()">Pobierz info o CD</button></p>
  6. <p><button onclick="loadXMLDocOne()">Pobierz info o CD wydanym w UK</button></p>
  7. <p><button onclick="loadXMLDocTwo()">Pobierz info o CD wydanym w USA</button></p>
  8. <p><button onclick="loadXMLDocThree()">Pobierz info o CD wydanym przez CBS</button></p>
  9. <p><button onclick="loadXMLDocFour()">Pobierz info o CD cenie ponizej 10</button></p>
  10. <p><button onclick="loadXMLDocFive()">Pobierz info o CD cenie powyzej 10</button></p>
  11.  
  12.  
  13. <table id="demo" border="1">
  14. <tr><th>Artist</th></tr>
  15. </table>
  16.  
  17. <script>
  18. function loadXMLDoc() {
  19. var xmlhttp = new XMLHttpRequest();
  20. xmlhttp.onreadystatechange = function() {
  21. if (this.readyState == 4 && this.status == 200) {
  22. myFunction(this);
  23. }
  24. };
  25. xmlhttp.open("GET", "catalog.xml" , true);
  26. xmlhttp.send();
  27. }
  28. function myFunction(xml) {
  29. var x, i, xmlDoc, table;
  30. xmlDoc = xml.responseXML;
  31. var table="<tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr>";
  32.   var x = xmlDoc.getElementsByTagName("CD");
  33.   for (i = 0; i <x.length; i++) {
  34.     table += "<tr><td>" +
  35.        x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
  36.     "</td><td>" +
  37.         x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
  38.     "</td><td>"+
  39.         x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue +
  40.     "</td><td>" +
  41.         x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue +
  42.     "</td><td>" +
  43.         x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue +
  44.     "</td><td>" +
  45.         x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue +
  46.     "</td></tr>";
  47. }
  48. document.getElementById("demo").innerHTML = table;
  49. }
  50.  
  51. //////////////////////////////////////////////////////////////////////////////////////
  52.  
  53. function loadXMLDocOne() {
  54. var xmlhttp = new XMLHttpRequest();
  55. xmlhttp.onreadystatechange = function() {
  56. if (this.readyState == 4 && this.status == 200) {
  57. myFunctionOne(this);
  58. }
  59. };
  60. xmlhttp.open("GET", "catalog.xml" , true);
  61. xmlhttp.send();
  62. }
  63. function myFunctionOne(xml) {
  64. var x, i, xmlDoc, table;
  65. xmlDoc = xml.responseXML;
  66. var table="<tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr>";
  67.   var x = xmlDoc.getElementsByTagName("CD");
  68.   for (i = 0; i <x.length; i++) {
  69.     if(x[i].getElementsByTagName("COUNTRY")[0].innerHTML=="UK")
  70.     {
  71.     table += "<tr><td>" +
  72.        x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
  73.     "</td><td>" +
  74.         x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
  75.     "</td><td>"+
  76.         x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue +
  77.     "</td><td>" +
  78.         x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue +
  79.     "</td><td>" +
  80.         x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue +
  81.     "</td><td>" +
  82.         x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue +
  83.     "</td></tr>";}
  84. }
  85. document.getElementById("demo").innerHTML = table;
  86. }
  87.  
  88. //////////////////////////////////////////////////////////////////////////////////////
  89.  
  90. function loadXMLDocTwo() {
  91. var xmlhttp = new XMLHttpRequest();
  92. xmlhttp.onreadystatechange = function() {
  93. if (this.readyState == 4 && this.status == 200) {
  94. myFunctionTwo(this);
  95. }
  96. };
  97. xmlhttp.open("GET", "catalog.xml" , true);
  98. xmlhttp.send();
  99. }
  100. function myFunctionTwo(xml) {
  101. var x, i, xmlDoc, table;
  102. xmlDoc = xml.responseXML;
  103. var table="<tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr>";
  104.   var x = xmlDoc.getElementsByTagName("CD");
  105.   for (i = 0; i <x.length; i++) {
  106.     if(x[i].getElementsByTagName("COUNTRY")[0].innerHTML=="USA")
  107.     {
  108.     table += "<tr><td>" +
  109.        x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
  110.     "</td><td>" +
  111.         x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
  112.     "</td><td>"+
  113.         x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue +
  114.     "</td><td>" +
  115.         x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue +
  116.     "</td><td>" +
  117.         x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue +
  118.     "</td><td>" +
  119.         x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue +
  120.     "</td></tr>";}
  121. }
  122. document.getElementById("demo").innerHTML = table;
  123. }
  124.  
  125. //////////////////////////////////////////////////////////////////////////////////////
  126.  
  127. function loadXMLDocThree() {
  128. var xmlhttp = new XMLHttpRequest();
  129. xmlhttp.onreadystatechange = function() {
  130. if (this.readyState == 4 && this.status == 200) {
  131. myFunctionThree(this);
  132. }
  133. };
  134. xmlhttp.open("GET", "catalog.xml" , true);
  135. xmlhttp.send();
  136. }
  137. function myFunctionThree(xml) {
  138. var x, i, xmlDoc, table;
  139. xmlDoc = xml.responseXML;
  140. var table="<tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr>";
  141.   var x = xmlDoc.getElementsByTagName("CD");
  142.   for (i = 0; i <x.length; i++) {
  143.     if(x[i].getElementsByTagName("COMPANY")[0].innerHTML=="CBS")
  144.     {
  145.     table += "<tr><td>" +
  146.        x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
  147.     "</td><td>" +
  148.         x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
  149.     "</td><td>"+
  150.         x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue +
  151.     "</td><td>" +
  152.         x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue +
  153.     "</td><td>" +
  154.         x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue +
  155.     "</td><td>" +
  156.         x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue +
  157.     "</td></tr>";}
  158. }
  159. document.getElementById("demo").innerHTML = table;
  160. }
  161.  
  162. //////////////////////////////////////////////////////////////////////////////////////
  163.  
  164. function loadXMLDocFour() {
  165. var xmlhttp = new XMLHttpRequest();
  166. xmlhttp.onreadystatechange = function() {
  167. if (this.readyState == 4 && this.status == 200) {
  168. myFunctionFour(this);
  169. }
  170. };
  171. xmlhttp.open("GET", "catalog.xml" , true);
  172. xmlhttp.send();
  173. }
  174. function myFunctionFour(xml) {
  175. var x, i, xmlDoc, table;
  176. xmlDoc = xml.responseXML;
  177. var table="<tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr>";
  178.   var x = xmlDoc.getElementsByTagName("CD");
  179.   for (i = 0; i <x.length; i++) {
  180.     if(x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue<10)
  181.     {
  182.     table += "<tr><td>" +
  183.        x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
  184.     "</td><td>" +
  185.         x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
  186.     "</td><td>"+
  187.         x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue +
  188.     "</td><td>" +
  189.         x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue +
  190.     "</td><td>" +
  191.         x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue +
  192.     "</td><td>" +
  193.         x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue +
  194.     "</td></tr>";}
  195. }
  196. document.getElementById("demo").innerHTML = table;
  197. }
  198.  
  199. //////////////////////////////////////////////////////////////////////////////////////
  200.  
  201. function loadXMLDocFive() {
  202. var xmlhttp = new XMLHttpRequest();
  203. xmlhttp.onreadystatechange = function() {
  204. if (this.readyState == 4 && this.status == 200) {
  205. myFunctionFive(this);
  206. }
  207. };
  208. xmlhttp.open("GET", "catalog.xml" , true);
  209. xmlhttp.send();
  210. }
  211. function myFunctionFive(xml) {
  212. var x, i, xmlDoc, table;
  213. xmlDoc = xml.responseXML;
  214. var table="<tr><th>Title</th><th>Artist</th><th>Country</th><th>Company</th><th>Price</th><th>Year</th></tr>";
  215.   var x = xmlDoc.getElementsByTagName("CD");
  216.   for (i = 0; i <x.length; i++) {
  217.     if(x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue>10)
  218.     {
  219.     table += "<tr><td>" +
  220.        x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue +
  221.     "</td><td>" +
  222.         x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue +
  223.     "</td><td>"+
  224.         x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue +
  225.     "</td><td>" +
  226.         x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue +
  227.     "</td><td>" +
  228.         x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue +
  229.     "</td><td>" +
  230.         x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue +
  231.     "</td></tr>";}
  232. }
  233. document.getElementById("demo").innerHTML = table;
  234. }
  235.  
  236. </script>
  237. </body>
  238. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top