test.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<newborns>
<newborn>
<nebo_birthno>123</nebo_birthno>
<nebo_sex>1</nebo_sex>
<nebo_birthtime>2011-09-01 15:13:30</nebo_birthtime>
</newborn>
</newborns>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
js怎么读取里面的值
<script type="text/javascript">
function GetChild(){
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","/test.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;var nebo_birthno=xmlDoc.getElementsByTagName("nebo_birthno").childNodes[0].nodeValue; //这句话该怎么写提示为空或不为对象   }
</script>

解决方案 »

  1.   

    var nebo_birthno=xmlDoc.getElementsByTagName("nebo_birthno")[0].childNode[0].nodeValue; 试试
      

  2.   

    http://blog.csdn.net/gnahshining/article/details/5113477
      

  3.   

    http://topic.csdn.net/u/20110831/11/5e3ea785-9946-475c-845d-e283f1b6be0e.html 参考
      

  4.   

    参考如下代码:
            <script>
                void function(){
                 var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
                 xmlhttp.open("get", "test.xml", true);
                 xmlhttp.onreadystatechange = function(){
                 if (xmlhttp.readyState != 4) return;
                 var xmldoc = xmlhttp.responseXML.documentElement;
                 if (!xmldoc) return;
                 var node = xmldoc.getElementsByTagName("nebo_birthno")[0];
                 var text = node.text || node.textContent;
                 alert(text);
                 }
                 xmlhttp.send(null);
                }();
            </script>
      

  5.   

    【函数】 boolean parse(String xmlCode, boolean showProgress) 
    【说明】 解析XML代码,解析成功后当前元素为根对象。 
    【返回】 成功或失败。 
    【参数】 xmlCode:要解析的XML代码。
    showProgress:是否显示进度条。 
    【示例】 alert(rexseeXML.parse(rexseeAjax.syncSubmit('/Eric/test.xml','','UTF-8'),true)); 
      

  6.   

    自己改一下路径吧。
    xmlhttp.open("get", "/test.xml", true);
      

  7.   

    xmlDoc.getElementsByTagName("nebo_birthno")[0].childNode[0].nodeValue;
      

  8.   

    xmlDoc.loadXml(xmlhttp.responseXML);
    楼主试试.
      

  9.   

    xmlDoc.loadXML(xmlhttp.responseXML);
    不好意思,上面写错了."xml"应该是大写的loadXML.