【发布时间】:2017-06-25 20:25:40
【问题描述】:
我从 W3Schools 下载了这个 books.xml 文件,并使用下面的代码 (with instructions from W3Schools) 对其进行了解析,但标题标签未出现在解析的代码中。
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags always come first -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
</head>
<body>
<p id="demo"></p>
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
console.log("Up to this line works.");
}
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
</script>
</body>
</html>
如何让标题标签也出现在结果中?
【问题讨论】:
标签: javascript html xml xml-parsing