日期:2014-05-16 浏览次数:20773 次
if(window.ActiveXObject)
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
else if(window.XMLHttpRequest)
var xmlDoc = new XMLHttpRequest();
xmlDoc.load("figures.xml");
var entries = xmlDoc.documentElement.childNodes;
var name=entries.item(0);
alert(name.text); //IE弹出提示框“姓名:XXX”,而FF就是不行
<entries>
<name>姓名:XXX</name>
</entries>
var loadXML = function(xmlFile){// 加载xml文档,返回XMLDOM
var xmlDoc;
if(window.ActiveXObject)
{
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.load(xmlFile);
}
else if (document.implementation&&document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument('', '', null);
xmlDoc.load(xmlFile);
}
else
{
return null;
}
return xmlDoc;
}