我有一个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