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>
<?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>
<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>
【说明】 解析XML代码,解析成功后当前元素为根对象。
【返回】 成功或失败。
【参数】 xmlCode:要解析的XML代码。
showProgress:是否显示进度条。
【示例】 alert(rexseeXML.parse(rexseeAjax.syncSubmit('/Eric/test.xml','','UTF-8'),true));
xmlhttp.open("get", "/test.xml", true);
楼主试试.
不好意思,上面写错了."xml"应该是大写的loadXML.