//生成XML文档对象
function NewXMLDocument()
{
 //return new ActiveXObject("MSXML2.DOMDocument");
 
 if (document.implementation && document.implementation.createDocument)
 {
  return document.implementation.createDocument("", "", null);
 }
 else if (window.ActiveXObject)
 {
  try
  {
   var prefix = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
   for (var i = 0; i < prefix.length; i++)
   {
    return new ActiveXObject(prefix[i] + ".DomDocument");
   }
  }
  catch (e)
  {
   alert("创建对象失败,应该是您浏览器版本太低了!");
  }
 }
 else
 {
  alert("创建对象失败,应该是您浏览器版本太低了!");
 }

}


本文转载:CSDN博客