0

My XML looks like this:

<photo>photo1.jpg</photo>
<photo>photo2.jpg</photo>

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!

1 Answer 1

1

Use join when you output:

myPhotoArray.join(",");

Actually, the comma is the default separator, so you could leave it out:

myPhotoArray.join();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.