如何将xml文件加载到html中 [英] how to load xml file into html
本文介绍了如何将xml文件加载到html中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将xml文件加载到html中以显示新闻自动收录器
how to load xml file into html to show news ticker
推荐答案
您需要对要执行的操作更加具体.
现在,将XML文件加载到HTML中以显示一些代码,您将需要一种将XML作为数据源的控件类型的控件.探索控件以及如何传递数据.
You need to be more specific on what are you trying to do.
For now, loading an XML file into HTML to show some ticker, you would need a ticker kind of control that takes XML as a datasource. Explore the control and how you can pass on the data.
<html>
<body>
<h1>W3Schools Internal Note</h1>
<div>
<b>To:</b> <span id="to"></span><br />
<b>From:</b> <span id="from"></span><br />
<b>Message:</b> <span id="message"></span>
</div>
<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","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
尝试这样
编辑(MtK):原始来源 [
try like this
Edit (MtK): Original Source[^]
这篇关于如何将xml文件加载到html中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文