Pawan
Pawan

Reputation: 32321

parsing an xml response

I have an XML Response as shown below

<?xml version="1.0" encoding="UTF-8"?>
<t0>
   <t9>0</t9>
   <t1>
      <t15>LUI</t15>
      <t3>1353.50</t3>
      <t6>25</t6>
      <t4>12.40</t4>
      <t5>0.92</t5>
      <t7>1342.50</t7>
      <t8>1368.90</t8>
        </t1>

<t1>
      <t15>LUI</t15>
      <t3>1233.50</t3>
      <t6>25</t6>
      <t4>12.40</t4>
      <t5>0.92</t5>
      <t7>1342.50</t7>
      <t8>1368.90</t8>
        </t1>

</t0>

From the XML response I want to read only the first root t1 tag and ignore the second t1 tag

I Culd able to do this with the help of Jquery

$(data).find("t1").each(function () {

    return false; 
});

i need to achieve this without returning false at the end .

taht is something like $(data).find("t1")[0]

Is that possible ??

Upvotes: 0

Views: 42

Answers (1)

Felix
Felix

Reputation: 38102

You've many ways to achieve it, one way is to use .first():

var firstT1 = $(data).find("t1").first();

Upvotes: 1

Related Questions