topical media & game development

talk show tell print

professional-xml-12-XmlValidation.htm / htm



  <html xmlns="http://www.w3.org/1999/xhtml">        
  <head>
    <title>Validating an XML Document</title>
    <script type="text/javascript" language="javascript">                        
      var doc;
          function btnValidate_Click()
          {
              loadDocument();            
          }
  
      function loadDocument()
      {        
          doc = new ActiveXObject("MSXML2.DOMDocument.6.0");                
          doc.resolveExternals = true;
          doc.validateOnParse = true;
          doc.async = false;
          if (doc.load("Products.xml"))
              alert("Document is valid");
          else    
              displayErrorInfo();        
      }        
      
      function displayErrorInfo()
      {
          document.write("Error code: " + doc.parseError.errorCode + "<br />");
              document.write("Error reason: " + doc.parseError.reason + "<br />");
              document.write("Error line: " + doc.parseError.line);       
      }   
      
    </script>        
  </head>
  <body>
      <input type="button" id="btnValidate" value="Validate XML Document" 
          onclick="btnValidate_Click()" />            
  </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.