RT 搞不动啊
网上搜的一用 都是不行的
html:
HTML code<html>
<body>
<script type="text/javascript">
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","photo.xml",false);/*IE这个就通不过*/
xmlhttp.send();/*Chrome 和 Opera 卡这里就完了 - -|||*/
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("path")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("info")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>
photo.xml:
XML code<?xml version="1.0" encoding="gb2312"?>
<root>
<item>
<photo1>
<path>/pic/pic1.jpg</path>
<info>一</info>
</photo1>
<photo2>
<path>/pic/pic2.jpg</path>
<info>二</info>
</photo2>
<info>三</info>
</item>
<item>
<photo1>
<path>/pic/pic1.jpg</path>
<info>一</info>
</photo1>
<photo2>
<path>/pic/pic2.jpg</path>
<info>二</info>
</photo2>
<info>三</info>
</item>
</root>
jquery读取 要找photo2 path的值写法
var path = $("photo2 path").text();