George

John

Reminder

Simth

以上是note.xml的内容。

下面note.html是解析note.xml的内容:

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:

转载于:https://my.oschina.net/u/2552902/blog/543958

标签:xml,childNodes,javascript,innerHTML,note,html,document,xmlDoc

来源: https://blog.csdn.net/weixin_34376562/article/details/92327037

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐