Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer 11 (IE 11) Throws Syntax Error using parseFromString in DOMParser

I have some Javascript on a webpage which works fine in Chrome and Firefox; when testing in IE 11 however it fails. I viewed the problem in IE 11 with the debug tools (F12) and the following code was at fault; specifically when using parseFromString a 'Syntax Error' is thrown:

if (window.DOMParser)
{                            
    parser =  new DOMParser();
    tmp = parser.parseFromString(resp, "text/xml");
}

Any way I can work around this?

like image 634
Gedalya Avatar asked Nov 10 '22 09:11

Gedalya


1 Answers

For IE this works for me

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(text);

source: http://www.w3schools.com/dom/dom_parser.asp

like image 91
Anshul Nigam Avatar answered Nov 15 '22 05:11

Anshul Nigam