Hi there.
Can you please look at my JavaScript and let me know if there's a more efficient way to write it in terms of looping through my XML?
My JavaScript code looks like this:
<script type="text/javascript">
function loadXMLDoc(dname)
{
xhttp=new XMLHttpRequest();
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}
var xmlDoc=loadXMLDoc("building.txt");
x=xmlDoc.getElementsByTagName('Building');
for (i=0;i<x.length;i++)
{
txt=xmlDoc.getElementsByTagName('Building')[i].getAttribute('Name');
document.write(txt + "<BR>");
y=x[i].getElementsByTagName('Tenant');
for (j=0;j<y.length;j++)
{
txt1=x[i].getElementsByTagName('Tenant')[j].getAttribute('DISPLAYNAME');
document.write("> " + txt1 + "<BR>");
}
document.write("<HR>");
}
My XML data looks like this - I pasted it in PasteBin... http://pastebin.com/nhMHjCjP