SHARE
TWEET

Untitled

a guest Oct 21st, 2019 66 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="loadXMLDoc1()">CD wydane w UK</button></p>
  7. <p><button onclick="loadXMLDoc2()">CD wydane w USA</button></p>
  8. <p><button onclick="loadXMLDoc3()">CD wydane przez CBS</button></p>
  9. <p><button onclick="loadXMLDoc4()">CD ponizej 10.00</button></p>
  10. <p><button onclick="loadXMLDoc5()">CD powyzej 10.00</button></p>
  11. <table id="demo" border="1">
  12. <tr><th>Artist</th></tr>
  13. </table>
  14.  
  15. <script>
  16. function loadXMLDoc() {
  17. var xmlhttp = new XMLHttpRequest();
  18. xmlhttp.onreadystatechange = function() {
  19. if (this.readyState == 4 && this.status == 200) {
  20. myFunction(this);
  21. }
  22. };
  23. xmlhttp.open("GET", "catalog.xml" , true);
  24. xmlhttp.send();
  25. }
  26. function myFunction(xml) {
  27. var x, i, xmlDoc, table;
  28. xmlDoc = xml.responseXML;
  29. table = "<tr><th>title</th><th>Artist</th><th>country</th><th>company</th><th>price</th><th>year</th></tr>";
  30. x = xmlDoc.getElementsByTagName("CD");
  31.  
  32. for (i = 0; i < x.length; i++) {
  33.  
  34. table += "<tr><td>" +
  35. x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td><td>" +
  36. x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" +
  37. x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue + "</td><td>" +
  38. x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue + "</td><td>" +
  39. x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue + "</td><td>" +
  40. x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue + "</td></tr>" ;
  41.  
  42. }
  43. document.getElementById("demo").innerHTML = table;
  44. }
  45.  
  46. function loadXMLDoc1() {
  47. var xmlhttp = new XMLHttpRequest();
  48. xmlhttp.onreadystatechange = function() {
  49. if (this.readyState == 4 && this.status == 200) {
  50. myFunction1(this);
  51. }
  52. };
  53. xmlhttp.open("GET", "catalog.xml" , true);
  54. xmlhttp.send();
  55. }
  56. function myFunction1(xml) {
  57. var x, i, xmlDoc, table;
  58. xmlDoc = xml.responseXML;
  59. table = "<tr><th>title</th><th>Artist</th><th>country</th><th>company</th><th>price</th><th>year</th></tr>";
  60. x = xmlDoc.getElementsByTagName("CD");
  61.  
  62. for (i = 0; i < x.length; i++) {
  63. if (x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue == "UK" ) {
  64.  
  65. table += "<tr><td>" +
  66. x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td><td>" +
  67. x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" +
  68. x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue + "</td><td>" +
  69. x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue + "</td><td>" +
  70. x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue + "</td><td>" +
  71. x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue + "</td></tr>" ;
  72. }
  73. }
  74. document.getElementById("demo").innerHTML = table;
  75. }
  76. function loadXMLDoc2() {
  77. var xmlhttp = new XMLHttpRequest();
  78. xmlhttp.onreadystatechange = function() {
  79. if (this.readyState == 4 && this.status == 200) {
  80. myFunction2(this);
  81. }
  82. };
  83. xmlhttp.open("GET", "catalog.xml" , true);
  84. xmlhttp.send();
  85. }
  86. function myFunction2(xml) {
  87. var x, i, xmlDoc, table;
  88. xmlDoc = xml.responseXML;
  89. table = "<tr><th>title</th><th>Artist</th><th>country</th><th>company</th><th>price</th><th>year</th></tr>";
  90. x = xmlDoc.getElementsByTagName("CD");
  91.  
  92. for (i = 0; i < x.length; i++) {
  93. if (x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue == "USA" ) {
  94.  
  95. table += "<tr><td>" +
  96. x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td><td>" +
  97. x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" +
  98. x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue + "</td><td>" +
  99. x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue + "</td><td>" +
  100. x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue + "</td><td>" +
  101. x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue + "</td></tr>" ;
  102. }
  103. }
  104. document.getElementById("demo").innerHTML = table;
  105. }
  106. function loadXMLDoc3() {
  107. var xmlhttp = new XMLHttpRequest();
  108. xmlhttp.onreadystatechange = function() {
  109. if (this.readyState == 4 && this.status == 200) {
  110. myFunction3(this);
  111. }
  112. };
  113. xmlhttp.open("GET", "catalog.xml" , true);
  114. xmlhttp.send();
  115. }
  116. function myFunction3(xml) {
  117. var x, i, xmlDoc, table;
  118. xmlDoc = xml.responseXML;
  119. table = "<tr><th>title</th><th>Artist</th><th>country</th><th>company</th><th>price</th><th>year</th></tr>";
  120. x = xmlDoc.getElementsByTagName("CD");
  121.  
  122. for (i = 0; i < x.length; i++) {
  123. if (x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue == "CBS" ) {
  124.  
  125. table += "<tr><td>" +
  126. x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td><td>" +
  127. x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" +
  128. x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue + "</td><td>" +
  129. x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue + "</td><td>" +
  130. x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue + "</td><td>" +
  131. x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue + "</td></tr>" ;
  132. }
  133. }
  134. document.getElementById("demo").innerHTML = table;
  135. }
  136. function loadXMLDoc4() {
  137. var xmlhttp = new XMLHttpRequest();
  138. xmlhttp.onreadystatechange = function() {
  139. if (this.readyState == 4 && this.status == 200) {
  140. myFunction4(this);
  141. }
  142. };
  143. xmlhttp.open("GET", "catalog.xml" , true);
  144. xmlhttp.send();
  145. }
  146. function myFunction4(xml) {
  147. var x, i, xmlDoc, table;
  148. xmlDoc = xml.responseXML;
  149. table = "<tr><th>title</th><th>Artist</th><th>country</th><th>company</th><th>price</th><th>year</th></tr>";
  150. x = xmlDoc.getElementsByTagName("CD");
  151.  
  152. for (i = 0; i < x.length; i++) {
  153. if (x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue < 10.00 ) {
  154.  
  155. table += "<tr><td>" +
  156. x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td><td>" +
  157. x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" +
  158. x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue + "</td><td>" +
  159. x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue + "</td><td>" +
  160. x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue + "</td><td>" +
  161. x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue + "</td></tr>" ;
  162. }
  163. }
  164. document.getElementById("demo").innerHTML = table;
  165. }
  166. function loadXMLDoc5() {
  167. var xmlhttp = new XMLHttpRequest();
  168. xmlhttp.onreadystatechange = function() {
  169. if (this.readyState == 4 && this.status == 200) {
  170. myFunction5(this);
  171. }
  172. };
  173. xmlhttp.open("GET", "catalog.xml" , true);
  174. xmlhttp.send();
  175. }
  176. function myFunction5(xml) {
  177. var x, i, xmlDoc, table;
  178. xmlDoc = xml.responseXML;
  179. table = "<tr><th>title</th><th>Artist</th><th>country</th><th>company</th><th>price</th><th>year</th></tr>";
  180. x = xmlDoc.getElementsByTagName("CD");
  181.  
  182. for (i = 0; i < x.length; i++) {
  183. if (x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue > 10.00 ) {
  184.  
  185. table += "<tr><td>" +
  186. x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "</td><td>" +
  187. x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "</td><td>" +
  188. x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue + "</td><td>" +
  189. x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue + "</td><td>" +
  190. x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue + "</td><td>" +
  191. x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue + "</td></tr>" ;
  192. }
  193. }
  194. document.getElementById("demo").innerHTML = table;
  195. }
  196. </script>
  197. </body>
  198. </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