IE10, 11 CDATA with hyphens parsed wrong

后端 未结 1 1347
你的背包
你的背包 2021-01-06 10:37

I experienced such problem: when trying to parse xml that I receive from server, messages contained in CDATA blocks are parsed in IE10, 11 till first hyphens found.

相关标签:
1条回答
  • 2021-01-06 11:17

    Have a look at this bug submission to IE11:

    https://connect.microsoft.com/IE/feedback/details/1398926/ie11-does-not-parse-cdata-containing-hyphens-correctly

    It appears the bug is fixed in Edge and IE11 (11.0.10240.16431), but for me I still get the bug on IE11.

    The bug can be summarized:

    new DOMParser().parseFromString('<tag><![CDATA[data-with-hyphen]]></tag>', 'text/xml').firstChild.firstChild.nodeValue;
    

    The result will have a truncated value located at the first occurrence of a hyphen.

    Edit: As a workaround, you can retrieve the contents using this format:

    response.getElementsByTagName('finish_msg')[0].textContent
    
    0 讨论(0)
提交回复
热议问题