Javascript - Getting data from XML for later use... put in array or object?
<p>I am extracting a bunch of data from an XML file using jQuery. I need to use the data to fill in image paths, names, etc.</p>

<p>What is the best way to gather all of this data for use? For instance, I get everything like so:</p>

<pre><code> $(document).ready(function() {
                $.ajax({
                    type: "GET",
                    url: "stuff.xml",
                    dataType: "xml",
                    success: function(xml) {
                        $(xml).find('speaker').each(function(){
                            var img_path = $(this).find('speaker_image').text();
                            var name_text = $(this).find('speaker_name').text();
                            // should I build an array or object here?
                        });
                    }
                });
            });
</code></pre>

<p>Should I stick everything into an array in the success method? Maybe in an object? What I will do is take the collected data and use it to build a list of names and images. There will be quite a few elements in this and it will look something like (with <code>img_path</code> being used in the image url and <code>name_text</code> being used for the label:</p>

<pre><code>&lt;ul&gt;
&lt;li&gt;&lt;img src="images/bobsmith.jpg" /&gt;&lt;br /&gt;&lt;lable&gt;Bob S. Smith&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src="images/crystalforehead.jpg" /&gt;&lt;br /&gt;&lt;lable&gt;Crystal X. Forehead&lt;/label&gt;&lt;/li&gt;
...
&lt;/ul&gt;
</code></pre>

<p>What is the best way to handle the collected data so I can go through and build the html I need using it?</p>
