0

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 ??

1 Answer 1

1

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

var firstT1 = $(data).find("t1").first();
Sign up to request clarification or add additional context in comments.

2 Comments

I tried this way as you suggested $(data).find("t1").first() { var symbol = $(this).find("t2").text(); } , but it didn't worked .
You need to use: var symbol = firstT1.find("t2").text(); or var symbol = $(data).find("t1").first().find("t2").text();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.