Nodejs Utililty Methods HTML Decode

List of utility methods to do HTML Decode

Description

The list of methods to do HTML Decode are organized into topic(s).

Method

htmlDecode(value)
function htmlDecode(value)
    if(value)
        return $("<div />").html(value).text();
    else
        return '';
...
htmlDecode()
String.prototype.htmlDecode = function() {
  return this.replace(/\&amp\;/g, '\&').replace(/\&gt\;/g, '\>').replace(
      /\&lt\;/g, '\<').replace(/\&quot\;/g, '\'').replace(/\&\#39\;/g,
      '\'');
};
htmlDecode()
String.prototype.htmlDecode = function () {
    var div = document.createElement('div');
    div.innerHTML = this;
    return div.innerText || div.textContent;
};
decodeHtml()
String.prototype.decodeHtml = function () {
    var string = new String(this);
    string = string.replace(/&lt;/g, "<");
    string = string.replace(/&gt;/g, ">");
    string = string.replace(/&quot;/g,  "\"")
    string = string.replace(/&39;/g,  "'");
    string = string.replace(/&amp;/g, "&");
    return string
decodeHtmlEntity()
String.prototype.decodeHtmlEntity = function(){
    var ta = document.createElement('textarea');
    ta.innerHTML = this;
    return ta.value;
};