title: XML file in Javascript, getElementByAttribute
body: <p>Let's suppose I have an XML file like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;MIDIFile&gt;
  
    &lt;Event&gt;
      &lt;Absolute&gt;0&lt;/Absolute&gt;
      &lt;NoteOn Channel="1" Note="40" Velocity="64"/&gt;
    &lt;/Event&gt;
    &lt;Event&gt;
      &lt;Absolute&gt;236&lt;/Absolute&gt;
      &lt;NoteOff Channel="1" Note="40" Velocity="0"/&gt;
    &lt;/Event&gt;
  
  &lt;/MIDIFile&gt;
  </code></pre>
  
  <p>Thanks to <a href="http://www.w3schools.com/xml/xml_to_html.asp" rel="nofollow noreferrer">some great tutorial</a> I now know how to get these values in my javascript.</p>
  
  <p>For example, I can iterate thru all the "Events" tag and get the "Absolute" value like this:</p>
  
  <pre><code>xmlhttp=new XMLHttpRequest();
  
  xmlhttp.open("GET","test.xml",false);
  xmlhttp.send();
  xmlDoc=xmlhttp.responseXML;
  
  // make an array with all the events from the xml file
  var events = xmlDoc.getElementsByTagName("Event")
  
  
  for (var i = 0; i&lt;events.length; i++)
  console.log(events[i].getElementsByTagName("Absolute")[0].childNodes[0].nodeValue)
  </code></pre>
  
  <p>this will return</p>
  
  <pre><code>0
  236
  </code></pre>
  
  <p>Now, how the hell can I access the "NoteOn" attribute and get its values? I want to iterate thru all the Events in the XML, see if they contains NoteOn or NoteOff and load an array with all the notes, their duration, velocity and channels.</p>
  
  <p>Please help me! <code>getElementsByTagName("NoteOn")</code> just doesn't work... If it might help, here are some screenshot of what happens if I <code>console.log(xmlDoc)</code></p>
  
  <p>Thanks a lot in advance!</p>
  
  <p><img src="https://i.stack.imgur.com/Dnhz7.png" alt="screen"></p>
  
  <hr>
  
  <p><strong>edit in response to an answer</strong>. As I try to do this:</p>
  
  <pre><code>var noteon = xmlDoc.getElementsByTagName('noteon');
  console.log(noteon)
  </code></pre>
  
  <p>the result is just this one</p>
  
  <pre><code>[]
  </code></pre>
  
  <p>re-edit:
  If I write "NoteOn" instead of "noteon" it works!</p>