Getting node values from XML and adding them to array?
My XML looks like this:
<photo>photo1.jpg</photo>
<photo>photo2.jpg</photo>
开发者_如何学C
I can get the value of each photo node by doing something like:
var myPhoto = $(this).find('photo').text();
I'm trying to get an array of nodes like so:
myPhotoArray.push(myPhoto);
When I push this to an array how do I add a comma separator for each node? It prints all the node values out on one line (photo1.jpgphoto2.jpg) Thank you!
Use join
when you output:
myPhotoArray.join(",");
Actually, the comma is the default separator, so you could leave it out:
myPhotoArray.join();
精彩评论