I am reading an XML data that is hosted on a server, then display it in an HTML document, for it I do the following:\[code\]var a1 = xml.getElementsByTagName('a1')[0].childNodes[0];var A1 = document.getElementById("A1");A1.innerHTML = a1.nodeValue;\[/code\]where a1 is the id of the XML stored on the server. This procedure I have it to do many times, where the only thing that changes is the id of the field, ie, I have this:\[code\]var a1 = xml.getElementsByTagName('a1')[0].childNodes[0];var a2 = xml.getElementsByTagName('a2')[0].childNodes[0];var a3 = xml.getElementsByTagName('a3')[0].childNodes[0];var a4 = xml.getElementsByTagName('a4')[0].childNodes[0];var a5 = xml.getElementsByTagName('a5')[0].childNodes[0];var A1 = document.getElementById("A1");var A2 = document.getElementById("A2");var A3 = document.getElementById("A3");var A4 = document.getElementById("A4");var A5 = document.getElementById("A5");A1.innerHTML = a1.nodeValue;A2.innerHTML = a2.nodeValue;A3.innerHTML = a3.nodeValue;A4.innerHTML = a4.nodeValue;A5.innerHTML = a5.nodeValue;\[/code\]Everything works fine and brings the data as expected, but my question is this, no way to optimize the code to not use as many lines as necessary, ie use something like\[code\]for (i=1;i<=5;i++){var a = xml.getElementsByTagName('a')[0].childNodes[0];}\[/code\]I do not know, is something that occurs to me, I'm new to this and have been generated that doubt, I appreciate any info, Greetings!