日期:2014-05-16 浏览次数:20359 次
var stringToDom=function(text) {
var doc;
if(window.ActiveXObject) {
doc = new ActiveXObject("MSXML2.DOMDocument");
doc.loadXML(text).documentElement;
} else {
doc = (new DOMParser()).parseFromString(text,"text/xml");
}
return doc;
}
var xmlDoc=stringToDom(" <body> <a href='a'>a </a> <a href='b'>b </a> </body>");
var c,d1=new Date();
for(var i=0;i <100000;i++){
c=xmlDoc.getElementsByTagName("a");
}
document.write("getElementsByTagName: ",new Date()-d1);
d1=new Date();
for(var i=0;i <100000;i++){
c=xmlDoc.selectNodes("a");//ff好像出不来
}
document.write(" <br/>selectNodes: ",new Date()-d1);