js读取xml文件

<html><head>
<script language="javascript">
function loadXml(){
var XmlDoc=new ActiveXObject("Microsoft.XmlDOM");
XmlDoc.async = false;
XmlDoc.load("note.xml");
Nodes=XmlDoc.documentElement.childNodes;
var ListNum=XmlDoc.getElementsByTagName("item").length;
var ListDesc="";
for(i=0;i<ListNum;i++) {
ListDesc=Nodes.item(i).childNodes(0).text+"&nbsp;"+Nodes.item(i).childNodes(1).text+"<br>"+ListDesc;
}
List.innerHTML=ListDesc;
}
</script>
</head>
<body onload="loadXml()">
<div id="List">Loading...</div>
</body>
</html>
===============================================

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">  
<item><musicname>歌曲1</musicname><singer>容畅</singer></item>
<item><musicname>歌曲2</musicname><singer>心动列车</singer></item>
<item><musicname>歌曲3</musicname><singer>真爱一世情</singer></item>
</rss>

posted @ 2008-11-30 16:57  Winner.Net(2007)  阅读(829)  评论(1编辑  收藏  举报