Advertisement
Guest User

secondo metodo

a guest
May 27th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <style>
  4. table, th, td {
  5.     border: 1px solid black;
  6.     border-collapse:collapse;
  7. }
  8. th, td {
  9.     padding: 5px;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14.  
  15. <script>
  16. if (window.XMLHttpRequest)
  17.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  18.   xmlhttp=new XMLHttpRequest();
  19.   }
  20. else
  21.   {// code for IE6, IE5
  22.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  23.   }
  24. xmlhttp.open("GET","cd_catalog.xml",false);
  25. xmlhttp.send();
  26. xmlDoc=xmlhttp.responseXML;
  27.  
  28. document.write("<table><tr><th>Artist</th><th>Title</th></tr>");
  29. var x=xmlDoc.getElementsByTagName("CD");
  30. for (i=0;i<x.length;i++)
  31.   {
  32.   document.write("<tr><td>");
  33.   document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
  34.   document.write("</td><td>");
  35.   document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
  36.   document.write("</td></tr>");
  37.   }
  38. document.write("</table>");
  39. </script>
  40.  
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement