当我尝试访问子节点时,我可以,但我无法访问它们的值,它显示为 null
     if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.open("GET","obj.xml",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;
    x=xmlDoc.getElementsByTagName("Objnode")[0].childNodes; 
    y=xmlDoc.getElementsByTagName("Objnode")[0].firstChild;    
    for (i=0;i<x.length;i++)
    {
    if (y.nodeType==1)
      {//Process only element nodes (type 1)
      document.write(y.nodeName + "<br>"); change it to y.nodeValue it says null!
      }
    y=y.nextSibling;
    }
我的xml就像
    <Objnode>
            <Object1>something</Object1>
            <Object2>something</Object2>
    </Objnode>
上面的代码有效,但行
document.write(y.nodeName + "<br>"); 
当将其更改为 y.nodeValue 时,它显示为空!