我的客户有一个Web应用程序,该应用程序开始在IE10中引发错误。我跟踪了错误的根源,似乎IE 10不再支持selectSingleNode。这是使用该函数的地方:



    ScormApi.prototype.setTom = function( tom ) {
         this.tom = CreateXmlDocument();
         var rootelem = importAllNode( this.tom, this.tomTemplate.documentElement, true );
         this.tom.appendChild( rootelem );
         // Transforms the tracing of the user in tracking template
         // Perform the navigation on all nodes of tom and for each value found
         // Sets it to this.tom
         rootelem = tom.selectSingleNode('//cmi');
         this.parseXML( rootelem, '/' , this, this.setTomParam );
    }


使用以下代码进行调用:


    var ajxreq = new Ajax.Request(
    this.baseurl+'?op=Initialize',
    {   method: 'post',
         asynchronous:false,
         postBody: strSoap,
         requestHeaders: {
             'Man':"POST " + this.baseurl + " HTTP/1.1",
             'Host':this.host,
             "Content-type":"text/xml; charset=utf-8",
             "SOAPAction":this.serviceid + "Initialize",
             "X-Signature":playerConfig.auth_request
         }
    });

    if( ajxreq.transport.status == 200 ) {
         try {
             this.setTom( ajxreq.transport.responseXML );
         }
    }


我找到了将响应类型更改为msxml-document,使用querySelector或使用jQuery的find函数的建议,但是我无法拼凑如何在此原型(prototype)框架中实际实现它。任何帮助将不胜感激。

最佳答案

至于http://doogalbellend.blogspot.fr/2012/04/cross-browser-selectsinglenode-for-xml.html

通过在选项中添加responseType: 'msxml-document'来修改您的请求应该可以。

10-05 21:03