javascript
html怎么加载xml文档,在html中解析xml文件(javascript 读取)
George
John
Reminder
Simth
以上是note.xml的內(nèi)容。
下面note.html是解析note.xml的內(nèi)容:
function parseXML(){
try{
xmlDoc= new ActiveXObject("Microsoft.XMLDOM");
}catch(e){
try{
xmlDoc= document.implementation.createDocument("","",null);
}catch(e){
alert(e.message);
return;
}
}
xmlDoc.async = false;
xmlDoc.load("../xml/note.xml");
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;
}
W3School.com.cn Internal Note
To:
From:
Message:
轉(zhuǎn)載于:https://my.oschina.net/u/2552902/blog/543958
標(biāo)簽:xml,childNodes,javascript,innerHTML,note,html,document,xmlDoc
來源: https://blog.csdn.net/weixin_34376562/article/details/92327037
總結(jié)
以上是生活随笔為你收集整理的html怎么加载xml文档,在html中解析xml文件(javascript 读取)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html桌面卡牌效果,html+css实
- 下一篇: html前端登录验证码,前端登录页面开发