topical media & game development

talk show tell print

professional-xml-12-TransformingXml.htm / htm



  <html xmlns="http://www.w3.org/1999/xhtml">        
  <head>
    <title>Transforming XML to HTML</title>
    <script type="text/javascript" language="javascript">                
          var xmlDoc;
          var xslDoc;
          function btnTransformXmlToHtml_Click()
          {
              loadDocuments();
              tranformXmlToHtml();            
          }
  
      function loadDocuments()
      {
          //Load the XML Document
          xmlDoc = new ActiveXObject("Microsoft.XMLDOM");        
          xmlDoc.async = false;
          xmlDoc.load("Products.xml");    
          //Load the XSL Document
          xslDoc = new ActiveXObject("Microsoft.XMLDOM");        
          xslDoc.async = false;
          xslDoc.load("Products.xsl");   
      }        
      
          function tranformXmlToHtml()
          {        
              var output = xmlDoc.transformNode(xslDoc);            
              result.innerHTML = output;
          }        
    </script>        
  </head>
  <body>
      <input type="button" id="btnTransformXmlToHtml" value="Transform XML" onclick="btnTransformXmlToHtml_Click()" />
      <br/><br/><br/>
      <div id="result">      
      </div>
  </body>                
  </html>        
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.