【发布时间】:2013-06-08 06:11:42
【问题描述】:
我正在使用以下脚本来解析 XML 文档并将其显示在网站上,这一切都很好,但是我在我的 html 文档中间内嵌了这个脚本。
它似乎阻止了我的页面加载大约 300 毫秒,所以我想把它放在文档的末尾来解决这个问题。
所以我的问题是......我怎样才能在文档末尾有这个脚本,但仍然在文档中间显示输出。
<script>
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET", "abc.xml", false);
xhttp.send();
xmlDoc = xhttp.responseXML;
x = xmlDoc.getElementsByTagName("xr")[0].attributes;
att = x.getNamedItem("value");
document.write(att.value);
</script>
谢谢!
【问题讨论】:
标签: xml parsing xmlhttprequest document.write