Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:57:45+00:00 2026-06-04T15:57:45+00:00

Let’s suppose I have an XML file like this: <?xml version=1.0 encoding=ISO-8859-1?> <MIDIFile> <Event>

  • 0

Let’s suppose I have an XML file like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<MIDIFile>

  <Event>
    <Absolute>0</Absolute>
    <NoteOn Channel="1" Note="40" Velocity="64"/>
  </Event>
  <Event>
    <Absolute>236</Absolute>
    <NoteOff Channel="1" Note="40" Velocity="0"/>
  </Event>

</MIDIFile>

Thanks to some great tutorial I now know how to get these values in my javascript.

For example, I can iterate thru all the “Events” tag and get the “Absolute” value like this:

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<events.length; i++)
console.log(events[i].getElementsByTagName("Absolute")[0].childNodes[0].nodeValue)

this will return

0
236

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.

Please help me! getElementsByTagName("NoteOn") just doesn’t work… If it might help, here are some screenshot of what happens if I console.log(xmlDoc)

Thanks a lot in advance!

screen


edit in response to an answer. As I try to do this:

var noteon = xmlDoc.getElementsByTagName('noteon');
console.log(noteon)

the result is just this one

[]

re-edit:
If I write “NoteOn” instead of “noteon” it works!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:57:47+00:00Added an answer on June 4, 2026 at 3:57 pm
    var noteon = xmlDoc.getElementsByTagName('noteon');
    var note = new Array;
    for(var i = 0; i < noteon.length; i++){
        note[i] = noteon[i].getAttribute('Note'); // or any of the attributes you want to get
    }
    

    Edit:

    If noteon = [] then you have 2 options you can put the whole thing in a try catch, not the best thing to do in javascript, or you can put it in an if statement. Something like this should work:

    var noteon = xmlDoc.getElementsByTagName('noteon');
    var noteoff = xmlDoc.getElementsByTagName('noteoff');
    var note = new Array;
    
    if(noteon != []){
        for(var i = 0; i < noteon.length; i++){
            note[i] = noteon[i].getAttribute('Note'); // or any of the attributes you want to get
    } else if(noteoff != []){
        for(var i = 0; i < noteoff.length; i++){
            note[i] = noteoff[i].getAttribute('Note'); // or any of the attributes you want to get
    } else{
        return;  //makes sure the function returns to the call even if nothing was found
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let’s say I have a number like 0x448 . In binary this is 0100
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have table with column 'URL' whrere I store urls like this
Let's suppose I have this piece of code. foreach(string value in myList) { string
Let's say that I have a set of relations that looks like this: relations
Let's say that I have classes like this: public class Parent { public int
Let's say I have some json like this in mongo: {n:5} and a java
Let's say we have this code: <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.