hh54188
hh54188

Reputation: 15626

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>
    </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:)

Upvotes: 1

Views: 4186

Answers (1)

Nick Craver
Nick Craver

Reputation: 630379

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

Upvotes: 2

Related Questions