Advertisement
Guest User

Untitled

a guest
Aug 19th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. <head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
  3. <title>Pet Shop</title>
  4. <link rel="stylesheet" type="text/css" href="style.css" />
  5. <script type="text/javascript">
  6. //The loadXMLDoc() function is used to load the XML and XSL files.
  7. //It checks what kind of browser the user has and loads the file.
  8. function loadXMLDoc(dname)
  9. {
  10. if (window.XMLHttpRequest)
  11. {
  12. xhttp=new XMLHttpRequest();
  13. }
  14. else
  15. {
  16. xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  17. }
  18. xhttp.open("GET",dname,false);
  19. xhttp.send("");
  20. return xhttp.responseXML;
  21. }
  22.  
  23.  
  24. function displayResult()
  25. {
  26. xml=loadXMLDoc("catalogue.xml"); <!--Loads the XML sheet information-->
  27. xsl=loadXMLDoc("catalogue.xsl"); <!--Loads the XSL sheet that styles the XML-->
  28. // code for IE
  29. if (window.ActiveXObject)
  30. {
  31. ex=xml.transformNode(xsl);
  32. document.getElementById("dog").innerHTML=ex; <!--This will cycle through the XML for all plant values-->
  33. document.getElementById("cat").innerHTML=ex; <!--This will cycle through the XML for all accessory product values-->
  34. }
  35. // code for Mozilla, Firefox, Opera, etc.
  36. else if (document.implementation && document.implementation.createDocument)
  37. {
  38. xsltProcessor=new XSLTProcessor();
  39. xsltProcessor.importStylesheet(xsl);
  40. resultDocument = xsltProcessor.transformToFragment(xml,document);
  41. document.getElementById("new_products").appendChild(resultDocument); <!--"new_products" is the id of a div tag where my information from XML is inserted into the HTML-->
  42. }
  43. }
  44. </script>
  45. </head>
  46. <body onload="displayResult()"> <!--Displays the XML/XSL on the page-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement