I am trying to write a code to read a XML file and add a row in HTML and display the contents. My code works fine but the problem is the last row element repeats in the first row. Please help. Following is the code

/*Xml file */
<Data RID="5"> </Data>
<Data RID="6"> </Data>
<Data RID="7"> </Data>
/* function to add row in the table */
function addRow(tableID)

var table = document.getElementById(tableID);

var rowCount = table.rows.length;
var row = table.insertRow(rowCount);

var colCount = table.rows[0].cells.length;

for(var i=0; i<colCount; i++) {

var newcell = row.insertCell(i);

newcell.innerHTML = table.rows[1].cells[i].innerHTML;
/* function to parse the value from the XML */
function getVal()
var xmlFile = loadXMLDoc("devListRes.xml");
var x = xmlFile.getElementsByTagName("Action");
var len = x[0].getAttribute('NOS');
var att = xmlFile.getElementsByTagName("Data");
var j = 0;

for(j=0 ;j < 2; j++ )

document.getElementById("room_no").innerHTML = att[j].getAttribute('RID');


<body onload="getVal()">
<table id="dataTable">
/* display the valueon HTML page */
<td>&nbsp;<div id= "room_no"></div></td>