I need to unescape strings in Javascript, but my string sometimes is already unescaped, and other times it is not:
// String 1
<?xml version="1.0" encoding="UTF-8" ?>
// String 2
<?xml version="1.0" encoding="UTF-8"?>
I use the following method:
function htmlDecode(input)
{
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
But the problem is that when I "decode" string 2, the answer comes out as ?xml version="1.0" encoding="UTF-8"?
Help is appreciated.