character-entities

Convert HTML Character Entities back to regular text using javascript

霸气de小男生 提交于 2019-11-27 04:38:22
the questions says it all :) eg. we have > , we need > using only javascript Update : It seems jquery is the easy way out. But, it would be nice to have a lightweight solution. More like a function which is capable to do this by itself. You could do something like this: String.prototype.decodeHTML = function() { var map = {"gt":">" /* , … */}; return this.replace(/&(#(?:x[0-9a-f]+|\d+)|[a-z]+);?/gi, function($0, $1) { if ($1[0] === "#") { return String.fromCharCode($1[1].toLowerCase() === "x" ? parseInt($1.substr(2), 16) : parseInt($1.substr(1), 10)); } else { return map.hasOwnProperty($1) ?

Is there a Java XML API that can parse a document without resolving character entities?

不羁岁月 提交于 2019-11-26 21:06:50
I have program that needs to parse XML that contains character entities. The program itself doesn't need to have them resolved, and the list of them is large and will change, so I want to avoid explicit support for these entities if I can. Here's a simple example: <?xml version="1.0" encoding="UTF-8"?> <xml>Hello there &something;</xml> Is there a Java XML API that can parse a document successfully without resolving (non-standard) character entities? Ideally it would translate them into a special event or object that could be handled specially, but I'd settle for an option that would silently

Convert HTML Character Entities back to regular text using javascript

China☆狼群 提交于 2019-11-26 12:28:55
问题 the questions says it all :) eg. we have > , we need > using only javascript Update : It seems jquery is the easy way out. But, it would be nice to have a lightweight solution. More like a function which is capable to do this by itself. 回答1: You could do something like this: String.prototype.decodeHTML = function() { var map = {"gt":">" /* , … */}; return this.replace(/&(#(?:x[0-9a-f]+|\d+)|[a-z]+);?/gi, function($0, $1) { if ($1[0] === "#") { return String.fromCharCode($1[1].toLowerCase() ==

Is there a Java XML API that can parse a document without resolving character entities?

和自甴很熟 提交于 2019-11-26 07:49:01
问题 I have program that needs to parse XML that contains character entities. The program itself doesn\'t need to have them resolved, and the list of them is large and will change, so I want to avoid explicit support for these entities if I can. Here\'s a simple example: <?xml version=\"1.0\" encoding=\"UTF-8\"?> <xml>Hello there &something;</xml> Is there a Java XML API that can parse a document successfully without resolving (non-standard) character entities? Ideally it would translate them into