javascript xml - How to find all nodes of the same type inside a node?



I have a xml file as response from a web service call with the following structure:



<LifeEvents>

<Event>
<eventid>
</eventid>

<eventtext>
</eventtext>

<eventplace>
</eventplace>

<Friend>
<Name> </Name>
</Friend>

<Friend>
<Name> </Name>
</Friend>

</Event>
.
.
.
.
.
</LifeEvents>


To have access to individual properties of a event in the xml file i do the following after i get the xml response from the web-service call:



$(xml).find('Event').each(function() {
var event_id = $(this).find('eventid').text();
var event_text = $(this).find('eventtext').text();
var event_place = $(this).find('eventplace').text();

});


But how can i have all friends as individual variables. because now i need to proccess all friends inside event. How can i achieve that?


No comments:

Post a Comment