开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜