Selecting the exact match from xml using jquery



Below is the sample XML.



<segment>
<departure-date-time>2015-01-31T10:40:00</departure-date-time>
<arrival-date-time>2015-01-31T14:00:00</arrival-date-time>
<data-details>
<stop-details>
<arrival-date-time>2015-01-31T12:25:00</arrival-date-time>
<departure-date-time>2015-01-31T13:00:00</departure-date-time>
<layover-duration>2100</layover-duration>
</stop-details>
</data-details>
</segment>


I want the value from the sample XML for that one i wrote



$('segment', this).each(function(index, element) {
var arr_tym =$(element).find('arrival-date-time').text();
console.log(arr_tym);
});


If i use like this i am getting the result, but it is taking the value of


also and printing as 2015-01-31T14:00:002015-01-31T12:25:00


actual output should be 2015-01-31T14:00:00. Can anyone help with this !!!!!


No comments:

Post a Comment