//here is my code.
//XMLFile.xml
<?xml version="1.0" encoding="utf-8" ?>
<peoples>
<person>
<name>A</name>
<sex>M</sex>
<mobile>11111111111</mobile>
</person>
<person>
<name>B</name>
<sex>F</sex>
<mobile>22222222222</mobile>
</person>
</peoples>

//js.js

if(window.ActiveXObject){
var doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.load("XMLFile.xml");
}
else if(document.implementation&&document.implementation.createDocument){
var parser=new DOMParser();
var doc=parser.parseFromString("XMLFile.xml", "text/xml");
}
else{
throw new Error("XML DOM is not supported!");
}

var rs="";
var name;
var x=doc.getElementsByTagName('person');
for(var i=0; i< x.length; i++){
name=x[i].firstChild.firstChild.nodeValue;
rs+=name + ", ";
}
document.write(rs);

//why doesn't it work? Nothing is displayed in the browser. Why??
//Help!!