Javascript 在Internet Explorer中使用XSL将DOM文档转换为片段

Javascript 在Internet Explorer中使用XSL将DOM文档转换为片段,javascript,xml,internet-explorer,xslt,Javascript,Xml,Internet Explorer,Xslt,在Firefox和Chrome中,我使用类似的东西使用XSL将XML文档转换为DOM片段: var xsl = document.implementation.createDocument(); // i.e. a DOM document var processor = new XSLTProcessor(); processor.importStylesheet(xsl); var xml = document.implementation.createDocument(); // i.e

在Firefox和Chrome中,我使用类似的东西使用XSL将XML文档转换为DOM片段:

var xsl = document.implementation.createDocument(); // i.e. a DOM document
var processor = new XSLTProcessor();
processor.importStylesheet(xsl);

var xml = document.implementation.createDocument(); // i.e. a DOM document
var fragment = processor.transformToFragment(xml, document);
在实际代码中,
xsl
xml
是使用数据类型为“xml”的jQuery从远程文件加载的,这两个xml文档也是如此

Internet Explorer中的等价物是什么?

试试看

// code for IE
if (window.ActiveXObject)
 {
 ex=xml.transformNode(xsl);
 document.getElementById("demo").innerHTML=ex;
 }
 // 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("demo").appendChild(resultDocument);
 }
}

在IE9中通过将XML文档转换为字符串并返回实现了这一点:我没有想到
XML.transformNode(xsl)只是工作,但显然是这样!