I've tried several methods to decode encoded xml using javascript. For some reason all of them ignore ' which causes it to fail. I can do a string.replace to fix the issue, but wondering why this happens or if there is some other method I should be using.
I've tried decodeURIComponent as well as another method I found on SO that puts the content in a div and then pulls it back out. Both ignore the '. I also tried unescape which curiously did nothing whatsoever. It is an xml block I am decoding.
This is the only way I could find to do it since no one responded:
function HtmlDecode(input) { var e = document.createElement('div'); e.innerHTML = input; return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue.replace(/'/g, "'");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.