开发者

How to use jquery get content with tags in xml

first I have an 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>
    </开发者_C百科html_code>
</app>

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());
   }

}); 

however, it only alert "links","id-1",but I want the <html_code>'s all content include <div> tags,

so how can I achieve that use jquery ?or I should back to javascript use "getxml"……

thank you:)


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());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜