var i = 0; var nod = xml_doc.firstChild; while (nod) { nod.attributes.ID = i++; nod = nod.NextNode(); trace(nod.firstChild); }