am not clear with the following line of code suppose we have a xml file containing : <label>text</label> // end of xml file allLinks = xhr.responseXML.getElementsByTagName("label")[0].firstChild; my question is why are we using the [0] . what is the function of [0]. ?
the square brackets indicate that this is an array. Arrays are numbered from 0 and not 1. So in this case you use [0] to get the first instance of the label element. if you have 3 label elements you would use [1] to get the second and [2] to get the third element. hope this helps.