tim
tim

Reputation: 970

Parsing XML with JQUERY - Sorting into two arrays

I'm trying to parse a little bit of XML with JQuery, I'd like to find the entries with updated status of 0 and add them to one array and do the same for updated statuses of 1 to a different array.

XML:

<entries>
   <upd>
      <updated>0</updated>
      <name>Adams</name>
   </upd>

   <upd>
      <updated>1</updated>
      <name>Dempsey</name>
   </upd>
</entries>

All I have as of right now is:

        $(xml).find("upd").each(function(){

        });

My main problem is distinguishing between an updated status of 1 or 0.

Upvotes: 0

Views: 183

Answers (1)

Joe
Joe

Reputation: 82654

$(xml).find("upd").each(function() {
    var updated = $(this).find("updated").text();
    console.log(updated); // 0 then 1
});

Continue down the same path. Example

Upvotes: 2

Related Questions