当我使用此代码时:
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "GET",
url: "nyhederlang.xml",
dataType: "xml",
success: parseXml,
error: function(){alert("Error: Something went wrong");}
});
});
function parseXml(xml)
{
//print the title and the description
$(xml).find("article").each(function()
{
$("#output").append("<div>");
$("#output").append("<b>" + $(this).find("title").text() + ":</b> <br />");
$("#output").append($(this).find("paragraphs").text());
$("#output").append("</div>");
});
}
</script>
我在#output 的开头同时得到了 div 和 /div。
为什么/div 没有放在#output 的末尾?
这是它的样子:
<div id="output">
<div></div>
<b>Some title text</b>
.
.
.
.
.