javascript read local xml

local xml

<?xml version="1.0" encoding="gb2312" ?>

<user>

  <username>admin</username>

  <password>123456</password>

</user>

html read xml:

<html>   
<head>  

<SCRIPT LANGUAGE="JavaScript">
var xdoc = new ActiveXObject("Microsoft.XMLDOM");
xdoc.async="true";
xdoc.load('test.xml');
nodes=xdoc.documentElement.childNodes;
document.write("<li>"+nodes.item(0).text+"</li><li>"+nodes.item(1).text+"</li>")
alert(nodes.item(0).text);
alert(nodes.item(1).text);
</SCRIPT>  
</head>   
<body >    
</body>   
</html> 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章