topical media & game development

talk show tell print

professional-ajax-04-XML-IE-DOMCreation.htm / htm



  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
      <title>Book XML Exercise</title>
      <script type="text/javascript">
          function createDocument() {
              var aVersions = [ "MSXML2.DOMDocument.5.0",
                  "MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0",
                  "MSXML2.DOMDocument","Microsoft.XmlDom"
              ];
          
              for (var i = 0; i < aVersions.length; i++) {
                  try {
                      var oXmlDom = new ActiveXObject(aVersions[i]);
                      return oXmlDom;
                  } catch (oError) {
                      //Do nothing
                  }        
              }
              throw new Error("MSXML is not installed.");
          }
          
          var oXmlDom = createDocument();
          
  
          oXmlDom.onreadystatechange = function () {
              if (oXmlDom.readyState == 4) {
              
                  var oRoot = oXmlDom.documentElement;
                  var oFirstBook = oRoot.firstChild;
                  
                  alert(oFirstBook.text);
              }
          };
  
          oXmlDom.load("books.xml");
  
      
      
      </script>
  </head>
  <body>
  
  </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.