我有一個xml文件,其中包含html標籤,我使用jquery ajax解析。 我可以毫無問題地獲得文本值。如何獲取元素中的html部分?jquery解析html中的xml
編輯:我試着在cdata中包裝html,但寧願在xml中有xhtml。
$.ajax({ type: "GET",
url: "product.xml",
dataType: "xml",
success: function (xml) {
$(xml).find("product[productid=" + selection + "]").each(function() {
var $title = $(this).find("title").text(); //get title
var $desc = $(this).find("description").html(); //get description
//$('[nodeName=]',xml)
$("#producttitle").html("");
$("#productdesc").append($desc);
$("#producttitle").append($title);
});
}
<product productid="1">
<title>Active Directory</title>
<status>noinfo</status>
<description>
Headline
<b>tester</b>
<ul>
<li>test list element</li>
</ul>
</description>
<link title=""></link>
</product>
乾杯, 特里
嗯,基本上平時jquery.ajax $阿賈克斯({類型: 「GET」, \t \t \t \t \t \t網址: 「product.xml」, \t \t \t \t \t \t數據類型: 「XML」, \t \t \t \t \t \t成功:功能(XML){....我得到使用var $ DESC = $值(本).find( 「說明」)文本(。 ); – 2011-06-08 10:08:36