title: Loading XML file into JavaScript Array
body: <p>I know this has been asked about a million times over, however all the scripts I've found either are taylored for the person asking the question or just don't work at all! Basically I'm limited to using normal JavaScript instead of a library like JQuery as its for a uni assignment, however would like to have stored for future use as sometimes JQuery isn't always an option.</p>
  
  <p>Anyway cutting to the chase. I have an XML file called "profiles.xml" which contains a fairly simple structure:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
   &lt;profiles&gt;
   &lt;profile id="1"&gt;
       &lt;pic&gt;images/profiles/person1/x.jpg&lt;/pic&gt;
       &lt;name&gt;Joe Bloggs&lt;/name&gt;
       &lt;nickname&gt;J-Bloggs&lt;/nickname&gt;
       &lt;age&gt;21&lt;/age&gt;
       &lt;email&gt;j.blogs@me.com&lt;/email&gt;
       &lt;role&gt;Web Site Manager&lt;/role&gt;
       &lt;likes&gt;
             &lt;like1&gt;Food&lt;/like1&gt;
             &lt;like2&gt;Drink&lt;/like2&gt;
             &lt;like3&gt;Computing&lt;/like3&gt;
             &lt;like4&gt;Music&lt;/like4&gt;
       &lt;/likes&gt;
       &lt;dislikes&gt;
             &lt;dislike1&gt;Rude People&lt;/dislike1&gt;
             &lt;dislike2&gt;Rude People&lt;/dislike2&gt;
       &lt;/dislikes&gt;
       &lt;favwebsite&gt;http://www.facebook.com&lt;/favwebsite&gt;
   &lt;/profile&gt;
  &lt;/profiles&gt;
  </code></pre>
  
  <p>So basically I'm wanting to load each profile into a seperate new array each time it needs to be accessed but in addition to that would like to do it based on the "id" attribute value. Is this possible? If so how? I've not got any time left to be learning stuff like XPATH etc... This needs to be done using JavaScript and that alone no server side scripting is allowed.</p>
  
  <p>Also as mentioned some scripts just simply don't work as when I try to put it into functions it comes up saying that certain variables aren't defined even when they have been set so need the script to be passing all the information from the XML file into the new Array and have it readily accessible throughout the entire HTML document.</p>
  
  <p>Please someone help, I've spent the past 4-5 weeks trying to work this out on my own as well as many sleepless nights searching on the net for scripts that might give me a clue!</p>
  
  <p>Any help is muchly appreciated! Thanks :-)</p>