当前位置:编程学习 > XML/UML >>

dwr convertXml的bug

读dwr的engine.js源码,看到convertXml这个方法:
[xhtml:showcolumns]
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
/** 
   * Marshall an object 
   * @private 
   * @see dwr.engine.serialize.convert() for parameter details 
   */ 
  convertXml:function(batch, referto, data, name, depth) { 
    var output; 
    if (window.XMLSerializer) output = new XMLSerializer().serializeToString(data); 
    else if (data.toXml) output = data.toXml; 
    else output = data.innerHTML; 
    return "xml:" + encodeURIComponent(output); 
  } 

里面用了XMLSerializer,这个在IE6下面不支持。
toXml,ff和ie6下面都undefined,估计是自定义转化xml的方法名吧。
最后一个data.innerHTML,是针对html dom对象的。
如果过传的是对象是构造的xml对象,如下构造的:
[xhtml:showcolumns]
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
function stringToXML(xmlData){ 
               if (window.ActiveXObject) { 
                   //for IE 
                   xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
                   xmlDoc.async = "false"; 
                   xmlDoc.loadXML(xmlData); 
                   return xmlDoc; 
               } 
               else  
                   if (document.implementation && document.implementation.createDocument) { 
                       //for Mozila 
                       parser = new DOMParser(); 
                       xmlDoc = parser.parseFromString(xmlData, "text/xml"); 
                       return xmlDoc; 
                   } 
           } 

这样传进去只有在ff下测试成功,执行的是这个方法XMLSerializer,IE6下报错error,
在网上查了下,上面说的ie9支持XMLSerializer这个。
呵呵。。。小弟看源码和测试的结果,不知道有错没,如果有请看到的大牛们指出来,谢谢?

摘自 懒人小何

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,