Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
- <title>Pet Shop</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- <script type="text/javascript">
- //The loadXMLDoc() function is used to load the XML and XSL files.
- //It checks what kind of browser the user has and loads the file.
- function loadXMLDoc(dname)
- {
- if (window.XMLHttpRequest)
- {
- xhttp=new XMLHttpRequest();
- }
- else
- {
- xhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xhttp.open("GET",dname,false);
- xhttp.send("");
- return xhttp.responseXML;
- }
- function displayResult()
- {
- xml=loadXMLDoc("catalogue.xml"); <!--Loads the XML sheet information-->
- xsl=loadXMLDoc("catalogue.xsl"); <!--Loads the XSL sheet that styles the XML-->
- // code for IE
- if (window.ActiveXObject)
- {
- ex=xml.transformNode(xsl);
- document.getElementById("dog").innerHTML=ex; <!--This will cycle through the XML for all plant values-->
- document.getElementById("cat").innerHTML=ex; <!--This will cycle through the XML for all accessory product values-->
- }
- // code for Mozilla, Firefox, Opera, etc.
- else if (document.implementation && document.implementation.createDocument)
- {
- xsltProcessor=new XSLTProcessor();
- xsltProcessor.importStylesheet(xsl);
- resultDocument = xsltProcessor.transformToFragment(xml,document);
- 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-->
- }
- }
- </script>
- </head>
- <body onload="displayResult()"> <!--Displays the XML/XSL on the page-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement