我有这样的xml文件
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web" cover="paperback">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
我想读取这个xml的所有值。即我需要所有节点的值。是否可以在不使用服务器端脚本语言的情况下读取所有节点的值。我用来读取xml所有标题的代码是下面给出。
<script type="text/javascript">
function loadXMLDoc()
{
//var item = document.getElementById('search').value;
var request = new XMLHttpRequest();
var url = "http://saletrack.cynere.net/test2.xml";
request.open("GET",url, true);
request.send();
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200 || request.status == 0) {
var myxml = request.responseXML;
var theHTML = '';
var x = myxml.getElementsByTagName("title");
for (var i = 0; i < x.length; i++) {
var y = x[i].childNodes[0].nodeValue;
theHTML += ['<div class="result"',
'<div ul="content">',
'<li><h3>'+y+'</h3></li>',
'</ul>',
'</div>'].join('');
}
}
}
document.getElementById('list').innerHTML = theHTML;
}
}
document.addEventListener("deviceready", loadXMLDoc, false);
</script>
提前致谢..........