【发布时间】:2018-10-21 06:01:43
【问题描述】:
如何将 .xml 文件中的注释内容输出到我的文本区域?
我的 .html:
<textarea name="comment" id="comment" rows="3"/>
我的 .xml:
<div>
<ab type="transcription"><!--This is a comment--></ab>
</div>
我的 .js:
$.ajax({
type: "GET",
url: "../data/cards/1799.xml",
dataType: "xml",
cache: false,
success: function (xml) {
[...]
var mycomment = $(xml).find("ab").attr("type", "transcription");
$("comment").val(mycomment)
.text() 不输出任何内容。提前感谢您对正确方向的任何提示!
【问题讨论】:
-
当你 console.log(mycomment) 在你的成功回调中,你得到什么了吗?
-
不,完全空白
-
PS:如果我用文本替换 xml 注释,我会得到它的输出。但我想要评论:)!
标签: javascript jquery html ajax xml