html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="button" value="看书" onclick="kan();">
</body>
<script type="text/javascript">
function kan() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (this.readyState == 4) {
var b = this.responseXML.getElementsByTagName('title')[1];
alert(b.childNodes[0].nodeValue);
};
}
xhr.open('get','1.xml',true);
xhr.send(null);
}
</script>
</html>
xml
<?xml version="1.0" encoding="utf-8"?>
<bookstore>
<book>
<title>天龙八部</title>
<author>金庸</author>
</book>
<book>
<title>七剑下天山</title>
<author>梁羽生</author>
</book>
</bookstore>
196

被折叠的 条评论
为什么被折叠?



