Question: I am trying to load an xml file that is on my local system. But I always get Network\_err. I do the following.

```
function LoadXmlDoc(dName)
{
    var xhttp;
    if(window.XMLHttpRequest)
    {
        xhttp = new XMLHttpRequest();
    }
    else
    {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    try
    {       
        xhttp.open("GET", "file.xml", false);
        xhttp.send();
    }
    catch(e)
    {       
        window.alert("Unable to load the requested file.");
        return;
    }
    return xhttp.responseXML;
}

```

How can I load an xml file that is on my system. all files are in same folder on my pc. Thanks

Answer: 
Firstly they way this im implemented is not awesome. There is a lot that could be done better but Im not going to try to change you implementation here... :)

To do what you want to do, that is access a global variable without knowing its actual name, can be done like this.

```
window[drugname + "qty"] = drugqty;

```

This works because

1. "Global" variable in a browser are actually on the window object
2. objects in JavaScript are associative arrays. Which in simple terms means you can access its properties via it name as you would in a Key Value pair
You could save all your quantities in a single object and add a property per drug.

```
var quantities = {};
quantities[drugname + "qty"] = drugqty;

```

But, if you want to display the results also, it might be easier to leave out the "qty"-part:

```
var quantities = {};
quantities[drugname] = drugqty;

```

And for displaying the results:

```
var html = "<table>";
for (var quantityName in quantities) {
  if (quantities.hasOwnProperty(quantityName)) {
    html += "<tr><td>" + quantityName + "</td>";
    html += "<td id='" + quantityName + "qty' align='center'>" + quantities[quantityName] + "</td></tr>";
  }
}
html += "</table>";

```