function loadXML(xmlFile){
    var xmlDoc;
    if(window.ActiveXObject){
        xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
    } else if (document.implementation.createDocument){
        xmlDoc = document.implementation.createDocument('','Root',null);  
    } else {
        return alert("Can not open the xml file ["+xmlFile+"]!");
    }
    xmlDoc.async = false;
    xmlDoc.load(xmlFile);
    return xmlDoc;
}
    var xmlDoc = loadXML(fileName);
    alert(xmlDoc );//这里得到的是object
    var vRootNode = xmlDoc.documentElement;//这里vRootNode竟然是null!!完全一样的的代码,
在纯html+js的demo applets里面运行完全正常!!为什么会这样?
有人遇到过吗?

解决方案 »

  1.   

    这个甚是奇怪。应该与jsf框架无关。是不是浏览器的问题呢?
      

  2.   


    function loadXML(xmlFile){
        var xmlDoc;
        if(window.ActiveXObject){
            xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
        } else if (document.implementation.createDocument){
            xmlDoc = document.implementation.createDocument('','Root',null);  
        } else {
            return alert("Can not open the xml file ["+xmlFile+"]!");
        }
        xmlDoc.async = false;
        xmlDoc.load(xmlFile);
        return xmlDoc;
    }
        var xmlDoc = loadXML(fileName);
        alert(xmlDoc );//这里得到的是object
        //var vRootNode = xmlDoc.documentElement;//这里vRootNode竟然是null!!
        var vRootNode = xmlDoc.getElementsByTagName("root");//root是节点名称