`
caozuiba
  • 浏览: 902875 次
文章分类
社区版块
存档分类
最新评论

JS读取XML

 
阅读更多
<iframe marginwidth="0" marginheight="0" src="http://218.16.120.35:65001/PC/Global/images/b.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>

<?xmlversion="1.0"encoding="utf-8"?>
<root>
<url>http://mat1.qq.com/luxury/images/2007/10/10/1.jpg</url>
<url>http://mat1.qq.com/luxury/images/2007/10/10/2.jpg</url>
<url>http://mat1.qq.com/luxury/images/2007/10/10/3.jpg</url>
</root>

JS 代码:

var imgList = new Array();
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async
= false;
xmlDoc.load(
"a.xml");
var imgItems = xmlDoc.selectNodes("//url");
for(var i=0;i<imgItems.length;i++)
{
imgList[i]
= imgItems.item(i).text;
document.write(imgList[i]
+ "<br/>");
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics