how to replace html code to normal chars

来源:互联网 发布:suse yast 安装软件 编辑:程序博客网 时间:2024/06/08 02:51

In javascirpt:

创建html节点,在取出节点的文本,创建的节点不用添加到Dom中

function getVal(str){
var temp=document.createElement("p");
temp.innerHTML=str;
return temp.firstChild.nodeValue;
}
var str='Tom & Jerry';
getVal(str) returns 'Tom & Jerry'.

in PHP:

html_entity_decode() 方法可以实现


http://www.webdeveloper.com/forum/showthread.php?136026-RESOLVED-convert-HTML-Entities-into-normal-characters

0 0