代码如下: function getNodeValue(node) { if(node && node.hasChildNodes()){ //return node.firstChild.nodeValue; var s="" //Mozilla has many textnodes with a size of 4096 //chars each instead of one large one. //They all need to be concatenated. for(var j=0;j<node.childNodes.length;j++){ s+=new String(node.childNodes.item(j).nodeValue); } return s; }else return ""; }