请问我以下的写法可以吗,
我想把html页面中id是15的这个div的outerHTML当作xml来处理,可以吗?var xmlDocRet;    
var divTree = document.getElementById("15");
    var divTreeString = divTree.outerHTML.toString();
    if (window.ActiveXObject) {
        xmlDocRet = new ActiveXObject('Microsoft.XMLDOM');
        xmlDocRet.async = false;
        xmlDocRet.loadXML(divTree);
    }
    else if (document.implementation && document.implementation.createDocument) {
        xmlDocRet = document.implementation.createDocument('', '', null);
        xmlDocRet.loadXML(divTree);
    }
 
xmlDocRet.loadXML(divTree);返回的是false,
读不进去,不知道是什么原因。能帮我分析一下原因吗?

解决方案 »

  1.   

    var divTreeString = divTree.outerHTML.toString();alert(divTreeString)
    然后发出这段给我看看~
      

  2.   

    <DIV id=15 PartsKBN="8" CDSinseiType="1000000015" KiteiFlg="0" Meisyo="Meisyo15" CallArray><TABLE>
    <TBODY>
    <TR style="VERTICAL-ALIGN: top">
    <TD id=tdRepeatId15>
    <TABLE style="MARGIN: 0px; WIDTH: 20px">
    <TBODY>
    <TR style="HEIGHT: 20px">
    <TD style="BACKGROUND-IMAGE: url(imgs/line2.gif)" id=tdImageId15></TD></TR></TBODY></TABLE></TD>
    <TD>
    <DIV id=divHighlightId15><IMG class=ec src="http://localhost:3024/WebSite1/risha.PNG"></IMG><LABEL>Meisyo15</LABEL></DIV>
    <DIV></DIV></TD></TR></TBODY></TABLE></DIV> 
      

  3.   

    <DIV id=15 => <DIV id="15"
    很明显这段html不符合xml格式
      

  4.   

    不符合xml。
    属性要""
    而且需是键值对