JavaScript DOMParser access innerHTML and other properties
Your current method fails, because HTML properties are not defined for the given XML document. If you supply the text/html MIME-type, the method should work. var string = ‘<!DOCTYPE html><html><head></head><body>content</body></html>’; var doc = new DOMParser().parseFromString(string, ‘text/html’); doc.body.innerHTML; // or doc.querySelector(‘body’).innerHTML // ^ Returns “content” The code below enables the text/html MIME-type for browsers which do … Read more