如何使用jQuery获取带有XML标签的内容 [英] How to use jquery get content with tags in xml
本文介绍了如何使用jQuery获取带有XML标签的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先我有一个xml:
<app id="id-1">
<html_code>
<div id="id-1" class="portlet">
<div class="portlet-header">Links</div>
<div class="portlet-content">id-1</div>
</div>
</html_code>
</app>
我想使用jquery $ .ajax获取标签中的内容 我用
I want use jquery $.ajax to get the content in tags I use
$.ajax({
……
success: function (xml) {
alert($(xml).find("app[id='id-1']").find("html_code").text());
}
});
但是,它仅警告链接","id-1",但我希望<html_code>
的所有内容都包含<div>
标记
however, it only alert "links","id-1",but I want the <html_code>
's all content include <div>
tags,
那么我如何实现使用jquery呢?或者我应该回到javascript使用"getxml"……
so how can I achieve that use jquery ?or I should back to javascript use "getxml"……
谢谢:)
推荐答案
您只需要使用 .html()
代替 .text()
来获得原始的未经过滤的优点,像这样:
You just need to use .html()
instead of .text()
to get the raw unfiltered goodness, like this:
alert($(xml).find("app[id='id-1']").find("html_code").html());
这篇关于如何使用jQuery获取带有XML标签的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文