//记住细节往往能让自己更有效率。定义变量,打冒号//XML文档空格bug补救方案function cleanWhiteSpace(element){element=element||document;var cur = element.firstChild;while(cur != null){ //如果是文本节点,并且只包含空格if(cur.nodeType == 3 && !/\S/.test(cur.nodeValue)){element.removeChild( cur );}else if( cur.nodeType == 1){cleanWhiteSpace( cur );} cur = cur.nextSibling;}}