简体   繁体   中英

How to display the multiple element inside a tag in xml using JavaScript/Jquery

I need to get the text of an element from a xml tag. The element can be repeated multiple times inside the same tag. I am able to get the number of occurrences of an element inside the tag, but I am not able to display the text. I am doing something like this

            getTo=$(this).find('TO');//.text();
            alert("the lenght is ::"+getTo.length);
            getToNode=$(this).children('TO').text(); 

The TO Element is repeated inside the tag. getTo.length gives me the number of occurrences inside the tag. Now I want to display their text with a separator between the text. Above code gives me the text of each and every element all together.

Please let me know the way to do this. Thanks!

Looks like the each function would help you.

http://api.jquery.com/each/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM