我一直在尝试使用 Javascript 将我的 XML 代码显示到 Div 中,但在 Internet Explorer 中无法正常工作,如下所示:
$('footer #xml_content').val($parsed.find('poem').html());
$('div#explanation').html($parsed.find('explanation').html());
虽然它确实与下面的函数一起工作,如 text()
但 XML 标签不会显示:
$('footer #xml_content').html($parsed.find('poem').text());
$('div#explanation').html($parsed.find('explanation').text());
谁能解出这个谜题? 谢谢!
function go_poem(pnum, poem, live, id_timer1, id_timer2, reset) {
$.ajax({
type: "GET",
url: _list_poems[ parseInt(pnum)-1 ],
dataType: "xml",
success: function (xml) {
var $parsed = $(xml);
var $texto = $parsed.find("texto");
$('footer #xml_content').html(
document.createTextNode( $('poem').html() )
);
$('div#explanation').html(
document.createTextNode( $('explanation').html() )
);
/* Remainder of code not included */
最佳答案
你必须转义所有<>
与 <
或 >
如果您真的想将这些标签显示为文本。
关于javascript - IE 9::使用 Javascript 将 XML 代码显示到 Div 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26983407/